私は以下のようでしたが、間違った情報がある:=プレースホルダ= Placeholderdtype = DT_STRING、形状: "InvalidArgumentError(トレースバックについては上記参照):DTYPE文字列 [[ノードを持つあなたは、プレースホルダテンソルの値を供給しなければならない『プレースホルダ』 []、_device = "/仕事:localhostの/レプリカ:0 /タスク:0/CPU:0"]]「なぜtf.placeholderが正しくフィードできないのですか?
pattern = tf.placeholder(tf.string, shape=[None])
filenames = tf.train.match_filenames_once(pattern[0])
count_num_files = tf.size(filenames)
filename_queue = tf.train.string_input_producer(filenames)
image_reader = tf.WholeFileReader()
image_name, image_file = image_reader.read(filename_queue)
with tf.Session() as sess:
tf.global_variables_initializer().run()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
feed_dict = {pattern: ['/home/test/images/*.jpg']}
out = sess.run(image_name, feed_dict)
coord.request_stop()
coord.join(threads)
私はすべてのステップがcorretだと思います。私が言ったように実際には機能しません。 どうしたのですか?私は本当にあなたの助けが必要です。それは私を長い間混乱させています。 よろしくお願いします!
Suppl。 ////////////////////// 下記の友人に感謝します。 もう1つの質問は、最初のプレースホルダー値を変更する方法です。 下のコードを見て、最初に空白としてinitを作って、次に文字列パターンに変更しますが、実際には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)
が私たちを表示トレースバック。 – user2357112