错误内容如下:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\10488\Desktop\data\train.py", line 74, in <module>
summary_str = sess.run(summary_op, feed_dict)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 967, in run
result = self._run(None, fetches, feed_dict, options_ptr,
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1190, in _run
results = self._do_run(handle, final_targets, final_fetches,
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1368, in _do_run
return self._do_call(_run_fn, feeds, fetches, targets, options,
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1394, in _do_call
raise type(e)(node_def, op, message)
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_5' with dtype float
[[node Placeholder_5 (defined at C:\Users\10488\Desktop\data\train.py:30) ]]
错误代码如下:
with tf.compat.v1.Session() as sess:
sess.run(init_op)
train_writer = tf.compat.v1.summary.FileWriter(logs_path, sess.graph)
saver = tf.compat.v1.train.Saver()
start_time1 = time.time()
for step in range(epoch):
# 生成车牌图像以及标签数据
img_batch, lbl_batch = get_batch()
start_time2 = time.time()
time_str = datetime.datetime.now().isoformat()
feed_dict = {image_holder:img_batch, label_holder:lbl_batch, keep_prob:0.6}
_1, _2, _3, _4, _5, _6, _7, ls1, ls2, ls3, ls4, ls5, ls6, ls7, acc = sess.run(
[train_op1, train_op2, train_op3, train_op4, train_op5, train_op6, train_op7,
loss1, loss2, loss3, loss4, loss5, loss6, loss7, accuracy], feed_dict)
summary_str = sess.run(summary_op, feed_dict)
train_writer.add_summary(summary_str,step)
duration = time.time() - start_time2
loss_total = ls1 + ls2 + ls3 + ls4 + ls5 + ls6 + ls7
if step % 10 == 0:
sec_per_batch = float(duration)
print('%s: Step %d, loss_total = %.2f, acc = %.2f%%, sec/batch = %.2f' %
(time_str, step, loss_total, acc * 100, sec_per_batch))
if step % 5000 == 0 or (step + 1) == epoch:
checkpoint_path = os.path.join(model_path,'./model.ckpt')
saver.save(sess, checkpoint_path, global_step=step)
end_time = time.time()
print("Training over. It costs {:.2f} minutes".format((end_time - start_time1) / 60))