【发布时间】:2023-03-19 08:53:02
【问题描述】:
我在编写这个非常简单的 tensorflow 代码时遇到了麻烦。我正在尝试进行 y = theta1 * x + theta2 形式的简单线拟合
我将 x 和 y 的数据创建为形状 [10] 的 numpy float32 数组,我创建了它们对应的占位符,如下所示:
tf_x = tf.placeholder(tf.float32, [10])
tf_y = tf.placeholder(tf.float32, [10])
我喂它们如下:
sess.run(train, feed_dict={tf_x: x_data, tf_y: y_data})
完整的代码有点长,所以我创建了一个要点: https://gist.github.com/meowmiau/369393f41b679dd95f4ac4e2e16b0782
我遇到的问题是这样的:
tensorflow.python.framework.errors.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [10]
[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[10], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
但是,据我所知,没有不匹配的地方。
【问题讨论】:
标签: python numpy tensorflow