当步幅大于 1 时,SAME 填充的行为是什么? [英] what is the behavior of SAME padding when stride is greater than 1?

查看:76
本文介绍了当步幅大于 1 时,SAME 填充的行为是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Tensorflow 中 SAME 填充的理解是添加了填充,以便输出尺寸(宽度和高度)与输入尺寸相同.然而,这种理解只有在 stride=1 时才真正有意义,因为如果 stride >1,那么输出维度几乎肯定会更低.

My understanding of SAME padding in Tensorflow is that padding is added such that the output dimensions (for width and height) will be the same as the input dimensions. However, this understanding only really makes sense when stride=1, because if stride is >1 then output dimensions will almost certainly be lower.

所以我想知道在这种情况下计算填充的算法是什么.是否只是添加了填充以便将过滤器应用于每个输入值,而不是在右侧保留一些?

So I'm wondering what the algorithm is for calculating padding in this case. Is it simply that padding is added so that the filter is applied to every input value, rather than leaving some off on the right?

推荐答案

有一个公式:

n' = floor((n+2*p-f)/s + 1)

n' = floor((n+2*p-f)/s + 1)

其中 n' 是输出大小,n 是输入大小,p 是填充,f 是过滤器大小,s 是步幅.

where n' is the output size, n is the input size, p is the padding and f is the filter size, s will be the stride.

如果您使用步长 > 1 的 SAME 填充,p 将是使 (n+2*p-f) 可被 s 整除的最小数.注意:p 可以是十进制,因为它会在图像的两侧取平均值.

If you are using SAME padding with stride > 1, p will be the minimum number to make (n+2*p-f) divisible by s. Note: p could be decimal as it will be averaged over two sides of the image.

这篇关于当步幅大于 1 时,SAME 填充的行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆