我已经用cnn模型和随机播放图像训练我的数据。第一卷积层被定义:tf.summary.image获取错误InvalidArgumentError
with tf.name_scope("conv1") as scope:
image = tf.placeholder(tf.float32, [FLAGS.batch_size, 32, 32, 1])
image = tf.reshape(image, [FLAGS.batch_size, 32, 32, 1])
print(image)
w_conv1 = weight_variable([7, 7, 1, 50])
tf.summary.histogram('w_conv1', w_conv1)
conv = tf.nn.conv2d(image, w_conv1, [1, 1, 1, 1], padding='SAME')
b_conv1 = bias_variable([50])
tf.summary.histogram('b_conv1', b_conv1)
conv1 = tf.nn.bias_add(conv, b_conv1)
tf.summary.image('conv1_img',conv1)# **this line get the error**
print('conv1:')
print(conv1)
如果删除行 “tf.summary.image( 'conv1_img',CONV1)”,程序可以成功地运行。当我加入这一行,错误:
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a
v alue for placeholder tensor 'conv1/Placeholder' with dtype float and shape [30,32,32,1]
发生,为什么呢?
感谢您详细的解释,这是真的很有帮助。我已经通过“sess.run(摘要,feed_dict {image:<您的图片在这里}}”解决了我的问题。“ – judyzha