【发布时间】:2017-06-11 15:06:51
【问题描述】:
我正在使用这些 these sources 在 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]
知道我做错了什么吗?
【问题讨论】:
标签: tensorflow padding convolution autoencoder