1

我想模仿这篇论文,他们使用完全连接的上采样层。我正在使用贡献conv3d_transpose,但概念应该与 2D 版本相同。

我有一个卷积层的输出[6,6,6,256]被馈送到应该输出的上采样层[13,13,13,128]。既然层应该是全连接的,那么过滤器应该是对的[13,13,13,128]吧?(减少特征图大小)

此外,步幅应该1正确吗?

也许我在想这个倒退,让我解释一下。过滤器定义了反向感受野的大小(完全由它组成)——位于输出层的权重矩阵的大小(因此是完整的[13,13,13,128])。EDIT INCORRECT [步幅是单个窗口在输入图像上移动的步幅长度。] --> 我现在明白,步幅也与输出层有关。例如,步长为 2 的过滤器大小为 2,将使输出维度加倍。这意味着对于一个完全连接的层,步幅应该是0,但这是不可能的......

我的上采样代码在这里:

temp_batch_size = tf.shape(x)[0] #batch_size shape
with tf.name_scope("deconv6") as scope:
    output_shape = [temp_batch_size, (n_input_z / 4), n_input_x / 4, n_input_y / 4, 128]
    strides = [1,1,1,1,1]
    conv7 = deconv3d(conv6, weights['wdc1'], biases['bdc1'], output_shape, strides, padding=1)
    conv7 = tf.reshape(conv7, [-1, n_input_x / 4, n_input_y / 4, (n_input_z / 4) * 128])
    conv7 = tf.contrib.layers.batch_norm(conv7)
    conv7 = tf.reshape(conv7, [-1, (n_input_z / 4), n_input_x / 4, n_input_y / 4, 128])

deconv函数如下所示:

def deconv3d(prev_layer, w, b, output_shape, strides, padding=0):
    # Deconv layer
    if padding == 0:
        deconv = tf.nn.conv3d_transpose(prev_layer, w, output_shape=output_shape, strides=strides, padding="SAME")
    else:
        deconv = tf.nn.conv3d_transpose(prev_layer, w, output_shape=output_shape, strides=strides, padding="VALID")
    deconv = tf.nn.bias_add(deconv, b)
    deconv = tf.nn.relu(deconv)
    return deconv

权重和偏差在这里:

'wdc1' : tf.get_variable("weights_7", shape=[13, 13, 13, 128, 256],
           initializer=tf.contrib.layers.xavier_initializer(), dtype=tf.float32),
...

'bdc1': tf.Variable(tf.zeros([128], dtype=tf.float32), name="biases_7", dtype=tf.float32),

通过调试,我可以验证输入和输出尺寸:

(Pdb) conv6
<tf.Tensor 'conv5_1/Reshape_1:0' shape=(?, 6, 6, 6, 256) dtype=float32>
(Pdb) output_shape
[<tf.Tensor 'strided_slice:0' shape=() dtype=int32>, 13, 13, 13, 128]

当我运行此代码时,我收到以下错误:

tensorflow.python.framework.errors.InvalidArgumentError: Conv3DBackpropInput: Number of planes of out_backprop doesn't match computed:  actual = 6, computed = 1
     [[Node: deconv6/conv3d_transpose = Conv3DBackpropInputV2[T=DT_FLOAT, padding="VALID", strides=[1, 1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/gpu:0"](deconv6/conv3d_transpose/output_shape, weights_7/read, conv5_1/Reshape_1)]]
     [[Node: deconv8/BatchNorm/moments/sufficient_statistics/Shape/_39 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_3797_deconv8/BatchNorm/moments/sufficient_statistics/Shape", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

我从第一Node行就假设问题deconv6出在deconv8.

4

0 回答 0