[英]Finding the amount of zeros to pad the input of a convolutional layer
我使用这些这些 资源打造tensorflow卷积的自动编码。 我知道我需要用零填充我的输入图像,以使解码器的输出等于原始输入。 作者给出了一个简单的例子,说明了正方形核的简单情况,并且步幅的值相等(垂直和水平)。 我需要针对我的输入概括此填充函数,但是我无法获得张量的正确形状。 到目前为止,我的功能是:
def _pad(self, input_x, filter_height, filter_width):
"""
pads input_x with the right amount of zeros.
Args:
input_x: 4-D tensor, [batch_side, widht, height, depth]
filter_side: used to dynamically determine the padding amount
Returns:
input_x padded
"""
# calculate the padding amount for each side
top_bottom_padding = filter_height - 1
left_right_padding = filter_width - 1
# pad the input on top, bottom, left, right, with amount zeros
return tf.pad(input_x,
[[0, 0], [top_bottom_padding, top_bottom_padding], [left_right_padding, left_right_padding], [0, 0]])
这给我
Shape of input: (10, 161, 1800, 1)
Shape of padded input: (10, 187, 1826, 1)
Shape of encoder output: (10, 187, 913, 15)
Shape of decoder output: (10, 187, 457, 15)
对于
num_outputs=15, kernel_size=14, stride=[1,2]
关于我在做什么错的任何想法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.