【问题标题】:tensorflow TypeError: run() got multiple values for argument 'feed_dict'tensorflow TypeError:run()为参数'feed_dict'获取了多个值
【发布时间】:2016-07-18 11:46:30
【问题描述】:

我在tensorflow中编写了这段代码,但是,当我运行它时,标题中的错误就出来了。谁能帮助我并向我解释这个问题?感谢您的帮助。

import tensorflow as tf
sess = tf.InteractiveSession()

import numpy as np


a = np.array([[1.0,2.0,3.0,4.0],[5.0,6.0,7.0,8.0],[9.0,10.0,11.0,12.0],[1.0,1.0,1.0,1.0]])
w = np.ones([3.0,3.0,1.0,1.0])

W_conv1 = tf.Variable(w)

def conv2d(x, W):
  return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')


x = tf.placeholder(tf.float64, shape=[4,4])

x_image = tf.reshape(x,[1,4,4,1])

h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1))

sess.run(tf.initialize_all_variables())

i,h1 = sess.run(x_image,h_conv1, feed_dict={x:a})

【问题讨论】:

    标签: python-3.x tensorflow multiple-value


    【解决方案1】:

    问题在于您将 h_conv1 作为要运行的第二个参数传递,即 feed_dict,然后还指定了命名参数 feed_dict。如果你想评估多个操作,你应该像这样在第一个参数中将它们作为数组传递:

    i,h1 = sess.run([x_image, h_conv1], feed_dict={x:a})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-20
      • 2019-09-15
      • 1970-01-01
      • 2022-11-17
      相关资源
      最近更新 更多