在tf.nn中“SAME”和“VALID”填充之间的区别是什么?tensorflow的Max_pool ?

在我看来,'VALID'意味着当我们做max pool时,边缘外不会有零填充。

根据深度学习卷积算法指南,它说池操作符中不会有填充,即只使用tensorflow的“VALID”。 但什么是'SAME'填充的最大池张量流量?


当前回答

有效填充是没有填充。 相同的填充在某种程度上是输出与输入大小相同的填充。

其他回答

有效填充是没有填充。 相同的填充在某种程度上是输出与输入大小相同的填充。

为了补充YvesgereY的回答,我发现这个可视化非常有用:

填充'valid'是第一个数字。滤镜窗口停留在图像内部。

填充'same'是第三个数字。输出是相同的大小。


在这篇文章里找到的

可视化致谢:vdumoulin@GitHub

Padding on/off. Determines the effective size of your input. VALID: No padding. Convolution etc. ops are only performed at locations that are "valid", i.e. not too close to the borders of your tensor. With a kernel of 3x3 and image of 10x10, you would be performing convolution on the 8x8 area inside the borders. SAME: Padding is provided. Whenever your operation references a neighborhood (no matter how big), zero values are provided when that neighborhood extends outside the original tensor to allow that operation to work also on border values. With a kernel of 3x3 and image of 10x10, you would be performing convolution on the full 10x10 area.

这里W和H是输入的宽和高, F为滤波器维数, P是填充大小(即要填充的行数或列数)

对于相同的填充:

对于有效填充:

TensorFlow Convolution的例子概述了SAME和VALID的区别:

对于相同的填充,输出的高度和宽度计算如下: Out_height = ceil(float(in_height) / float(strides[1])) Out_width = ceil(float(in_width) / float(strides[2]))

And

对于VALID填充,输出高度和宽度的计算如下: Out_height = ceil(float(in_height - filter_height + 1) / float(strides[1])) Out_width = ceil(float(in_width - filter_width + 1) / float(strides[2]))