我正在实施一个卷积自动编码器,它必须实时减少每个图像的摄像机图像尺寸。因此我的批量是一个。 Y_pred是网络的输出。我想评估这个,以便我可以看到我的网络正在输出什么。
这是我用来导入数据并提供占位符的代码:
def inputs(image_file_path):
filenames = [image_file_path]
filename_queue = tf.train.string_input_producer(filenames)
read_input = read_image(filename_queue)
return read_input
with tf.Session() as sess:
image = inputs(file_path)
coord = tf.train.Coordinator()
init = tf.global_variables_initializer()
sess.run(init)
threads = tf.train.start_queue_runners(sess=sess, coord = coord)
image = tf.cast(image/255, tf.float32)
###data is just one image, so I set the dimension [batch, height, width, channels] to [1,120,160,3]
image = tf.reshape(image, [1, 120,160,3])
X_data = image.eval()
sess.run(train_step,{X_input:X_data, Y_true: X_data})
output = Y_pred
###Everything works fine up until this point.
print(Y_pred.eval())
coord.request_stop()
coord.join(threads)
然后占位符在这里:
X_input = tf.placeholder(tf.float32, [None,120,160,3])
Y_true = tf.placeholder(tf.float32, [None,120,160,3])
我得到的错误:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1039, in _do_call
return fn(*args)
File "C:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1021, in _run_fn
status, run_metadata)
File "C:\Python35\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "C:\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float
[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Julian\workspaceNeon\Scriptie\Autoencoder\__init__.py", line 164, in <module>
print(output.eval())
File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 569, in eval
return _eval_using_default_session(self, feed_dict, self.graph, session)
File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3741, in _eval_using_default_session
return session.run(tensors, feed_dict)
File "C:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 778, in run
run_metadata_ptr)
File "C:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "C:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "C:\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float
[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Caused by op 'Placeholder', defined at:
File "C:\Users\Julian\workspaceNeon\Scriptie\Autoencoder\__init__.py", line 50, in <module>
X_input = tf.placeholder(tf.float32, [None,120,160,3])
File "C:\Python35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1507, in placeholder
name=name)
File "C:\Python35\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1997, in _placeholder
name=name)
File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 768, in apply_op
op_def=op_def)
File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1228, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype float
[[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]