我正在使用这些these sources在tensorflow中构建卷积自动编码器。我知道我需要用零填充输入图像,以使解码器的输出等于原始输入。 作者给出了一个简单的方形内核和strides(vertical和horrizontal)值相等的例子。我需要为我的输入概括这个填充函数,但是我无法得到正确的张量形状。到目前为止我的功能是:
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]
对我做错了什么的任何想法?