如何在张量流中打印或写入卷积层输出的文件

时间:2017-07-23 09:27:41

标签: python tensorflow deep-learning conv-neural-network

代码:

conv2 = conv2d(conv1, weights['wc2'], biases['bc2'])
# Max Pooling (down-sampling)
conv2 = maxpool2d(conv2, k=2)
with tf.Session() as sess:
    print(sess.run(conv2))
  • 我使用过此,但收到以下错误消息:
  

InvalidArgumentError(请参阅上面的回溯):您必须提供值   对于带有dtype float的placeh较旧的张量'占位符'            [[Node:Placeholder = Placeholderdtype = DT_FLOAT,shape = [],_ device =“/ j ob:localhost / replica:0 / task:0 / cpu:0”]]

1 个答案:

答案 0 :(得分:1)

conv1生成了对占位符张量的一些操作。您应该将数据提供给来电sess.run(conv2)。来自this pagetf.placeholder示例:

x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)

with tf.Session() as sess:
    print(sess.run(y))  # ERROR: will fail because x was not fed.

    rand_array = np.random.rand(1024, 1024)
    print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.