我已经为反卷积层编写了代码,
def deconv2d(x, W,stride):
x_shape = tf.shape(x)
output_shape = tf.stack([x_shape[0], x_shape[1]*2, x_shape[2]*2, x_shape[3]//2])
decon = tf.nn.conv2d_transpose(x, W, output_shape, strides=[1, stride, stride, 1], padding='SAME')
layer_shape = get_layer_shape(decon)
print('DECONV Shape : ', layer_shape)
return decon
我已经像这样调用了上面的函数,
deconvolution1 = deconv2d(x=cnn_layer10, W=[2,2,512,1024], stride=2)
收到此错误,
文件“u-net.py”,第 84 行,在 obj.computation() 文件“u-net.py”,第 41 行,计算中 deconvolution1 = deconv2d(x=cnn_layer10, W=[2,2,512,1024], stride=2) 文件“/home/shuvo/u-net/architecture.py”,第 35 行,在 deconv2d decon = tf.nn.conv2d_transpose(x, W, output_shape, strides=[1, stride, stride, 1] , padding='SAME') 文件“/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/nn_ops.py”,第 1019 行,在 conv2d_transpose 如果不是 value.get_shape()[axis] .is_compatible_with(filter.get_shape()[3]):
文件“/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/tensor_shape.py”,第500行,在getitem中 返回self._dims [key] IndexError:列表索引超出范围
我的意图是在形状应该是 [batch_size, 36,36,1024]=>[batch_size,72,72,512] 的地方制作一个反卷积层。请帮我解决这个错误,