感谢您的帮助。
conv2d_transpose中存在valueError。
[mini_batch,150,2,20]将被转换为[mini_batch,300,4,1]
h3 = tf.nn.relu(self.g_bn0(linear(h2_, 6000, 'm_h3_lin')))
h3_ = tf.reshape(h3, [self.batch_size, 150, 2, 20])
h4_1 = deconv2d(h3_, [2, 2, 1, 20], [2, 2], [self.batch_size, 300, 4, 1], name='g_h4_1')
def deconv2d(input_, kernels, strides, output_shape, stddev=0.02, name="deconv2d", with_w=False):
d_h, d_w = strides
with tf.variable_scope(name):
# filter : [height, width, output_channels, in_channels]
w = tf.get_variable('w', kernels,
initializer=tf.random_normal_initializer(stddev=stddev))
deconv = tf.nn.conv2d_transpose(input_, w, output_shape=output_shape,
strides=[1, d_h, d_w, 1])
biases = tf.get_variable('biases', [output_shape[-1]],
initializer=tf.constant_initializer(0.0))
deconv = tf.reshape(tf.nn.bias_add(deconv, biases), deconv.get_shape())
return deconv
和错误评论:
ValueError:运算输入和计算的输入梯度之间的形状不兼容。正向操作:generator / g_h4_1 / conv2d_transpose。输入索引:2。原始输入形状:(256,150,2,20)。计算得出的输入梯度形状:(256、300、4、20)