如何解释TensorFlow的卷积滤波器和步幅参数? [英] How to interpret TensorFlow's convolution filter and striding parameters?
问题描述
我试图了解TensorFlow的卷积,尤其是公式
I'm trying to understand TensorFlow's convolution, in particular the formula
shape(output) = [batch,
(in_height - filter_height + 1) / strides[1],
(in_width - filter_width + 1) / strides[2],
...]
我希望公式为
shape(output) = [batch,
(in_height - filter_height) / strides[1] + 1,
(in_width - filter_width) / strides[2] + 1,
...]
。从32x32图像开始,并应用带有步幅[1,3,3,1]的5x5滤镜,然后以我的理解,这应该会产生10x10的输出,其值是面积的卷积
instead. Starting from a 32x32 image, and applying a 5x5 filter with strides [1,3,3,1], then in my understanding this should yield a 10x10 output, whose values are the convolutions of the areas
(0:4,0:4) , (0:4,3:7) , (0:4,6:10) , ..., (0:4,27:31),
(3:7,0:4) , (3:7,3:7) , (3:7,6:10) , ..., (3:7,27:31),
...
(27:31,0:4), (27:31,3:7), (27:31,6:10), ..., (27:31,27:31)
所以两个尺寸都应为地板((32 -5)/ 3)+ 1 = 10,而不是floor((32-5 + 1)/ 3)= 9。我在这里想念什么?我是否误解了这里的卷积方式和/或参数的含义?如果是这样,我应该使用什么参数来获得上述选择?
so both dimensions should be floor((32-5)/3)+1=10 and not floor((32-5+1)/3)=9. What am I missing here? Have I misunderstood the way convolution is done here and/or what the parameters mean? If so, what parameters should I use in order to obtain the above selection?
推荐答案
根据问题#196 ,这部分文档显然是错误的;我认为dga的答案仍然存在问题。
According to issue #196, this part of the documentation is apparently wrong; and I think there is still problem in dga's answer.
应为:
floor((in_height + y_padding-filter_height)/ y_stride)+ 1,
floor((in_height+y_padding-filter_height)/y_stride) + 1,
- 当padding = VALID时,y_padding = 0。
- 当padding = SAME时,通常y_padding进行调整以使(in_height + y_padding-filter_height)/ y_stride为整数,从而不必使用地板。
这篇关于如何解释TensorFlow的卷积滤波器和步幅参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!