Python 为什么tf.placeholder不能正确工作以馈送?

Python 为什么tf.placeholder不能正确工作以馈送?,python,tensorflow,Python,Tensorflow,我做了如下操作,但错误的信息是: “InvalidArgumentError(回溯见上文):必须为带有数据类型字符串的占位符张量'placeholder'提供一个值 [[Node:Placeholder=Placeholderdtype=DT_STRING,shape=[],_device=“/job:localhost/replica:0/task:0/cpu:0”]” 我认为每一步都是正确的。但它确实不像我所说的那样起作用。 怎么了?我真的需要你的帮助,这让我困惑了很久。 非常感谢你 补充。

我做了如下操作,但错误的信息是: “InvalidArgumentError(回溯见上文):必须为带有数据类型字符串的占位符张量'placeholder'提供一个值 [[Node:Placeholder=Placeholderdtype=DT_STRING,shape=[],_device=“/job:localhost/replica:0/task:0/cpu:0”]

我认为每一步都是正确的。但它确实不像我所说的那样起作用。 怎么了?我真的需要你的帮助,这让我困惑了很久。 非常感谢你

补充。 //////////////////////////// 谢谢下面的朋友给出答案。 另一个问题是如何更改初始占位符值。 看下面的代码,首先我将y下的placehoder初始化为空“”,然后我将其更改为字符串模式,但事实上,y始终为空“”,没有更改,如何将y更改为另一个值?非常感谢

pattern = '/home/lyp/MyTensorflowData/TestProject/images/*.jpg'
y = tf.placeholder(tf.string)
filenames = tf.train.match_filenames_once(y)
count_num_files = tf.size(filenames)

init_op = tf.global_variables_initializer()

with tf.Session() as sess:
  sess.run(init_op, feed_dict={y: ''})
  coord = tf.train.Coordinator()
  threads = tf.train.start_queue_runners(coord=coord)

  for epoch in range(3):
    print(sess.run(count_num_files, feed_dict={y: pattern}))


coord.request_stop()
coord.join(threads)

我认为问题在于如何初始化变量。事实上,我并不完全确定原因,但这对我来说很有效(v0.1.0):

tf.global\u variables\u initializes().run(feed\u dict)


似乎要初始化变量,您需要传入feed_dict

向我们显示回溯。非常感谢。它在这里起作用。但是如果我想在循环中更改feed_dict值,看起来有点困难。有什么好主意吗?”
pattern = '/home/lyp/MyTensorflowData/TestProject/images/*.jpg'
y = tf.placeholder(tf.string)
filenames = tf.train.match_filenames_once(y)
count_num_files = tf.size(filenames)

init_op = tf.global_variables_initializer()

with tf.Session() as sess:
  sess.run(init_op, feed_dict={y: ''})
  coord = tf.train.Coordinator()
  threads = tf.train.start_queue_runners(coord=coord)

  for epoch in range(3):
    print(sess.run(count_num_files, feed_dict={y: pattern}))


coord.request_stop()
coord.join(threads)