我想在tensorflow中为FCN模型实现解卷积层,我使用tf.nn.conv2d_transpose作为5个卷积输出中的每一个,我需要的是5个解卷积中的每一个的输出形状与输入图像形状相同。所以我设置了
deconv_shape = tf.shape(input)
tf.nn.conv2d_transpose(value=deconv5_1,
filter=[32, 32, 1, 1],
output_shape=deconv_shape,
strides=16,
padding="same",
name="deconv5_2")我做得对吗?
发布于 2017-08-17 15:18:26
我认为你的实现是不正确的,下面是几个正确的步骤。
in_channels = input.shape[-1]
# here set the output_height, width as [stride*input_height, stride*input_width]]
output_shape = [batch_size, output_height, output_width, out_channels]
filter_size =2 # for example
stride = 2 # for example if you want 2x scale of input height, width
shape = [filter_size, filter_size, out_channels, in_channels]
w = tf.get_variable(
name='W',
shape=shape,
initializer=w_init,
regularizer=w_regularizer,
trainable=trainable
)
output = tf.nn.conv2d_transpose(
input, w, output_shape=output_shape, strides=[1, stride, stride, 1])https://stackoverflow.com/questions/45725642
复制相似问题