使用Tensorflow.slim应用convolution2d_transpose

时间:2017-02-13 10:14:58

标签: tensorflow convolution tf-slim deconvolution

我正在尝试使用tf.slim.conv2d函数应用2个卷积层,它们基本上每次将输入图像的大小减半。然后我想应用convolution2d_transpose来恢复原始图像形状。问题是我不知道如何使用转置卷积功能,并且文档没有多大帮助。

我正在使用自定义包装器,但这是我到目前为止所拥有的:

Input Batch [8, 161, 141] ----> Conv2d [outputs = 32, 
kernel_size = [41,11], stride= [2,2]] 
which cuts the original image in half, and another such layer which cuts it again.

如何应用convolution_transpose函数来反转这两层的效果呢?

1 个答案:

答案 0 :(得分:1)

根据您在上面提供的tensorflow api-docs链接:

def convolution2d_transpose(
inputs,
num_outputs,
kernel_size,
stride=1,
padding='SAME',
data_format=DATA_FORMAT_NHWC,
activation_fn=nn.relu,
normalizer_fn=None,
normalizer_params=None,
weights_initializer=initializers.xavier_initializer(),
weights_regularizer=None,
biases_initializer=init_ops.zeros_initializer(),
biases_regularizer=None,
reuse=None,
variables_collections=None,
outputs_collections=None,
trainable=True,
scope=None):
例如,你可以像这样使用它:

slim.convolution2d_transpose(input_tensor, 32, [4,4], [2,2], scope='output')