Tensorflow:如何在不触发出队的情况下运行汇总操作 [英] Tensorflow: how to run summary operation without triggering dequeue

查看:38
本文介绍了Tensorflow:如何在不触发出队的情况下运行汇总操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Tensorflow 编写脚本来训练网络.我有一些要求:

I am trying to write a script with Tensorflow to train a network. I have some requirements:

  1. 我需要使用FIFOqueue来加载训练数据集和验证数据集;训练数据集的num_epoches设置为10,但验证数据集的num_epoches设置为1,因为在测试中,我们只需要运行整个验证数据集一次.
  2. 我需要使用验证数据集在几个训练步骤后测试网络,而不是在单独的脚本中使用训练脚本保存的检查点文件;
  3. 我需要将 lossaccuracy_validation 数据存储到摘要文件中,以便在 Tensorboard 中进行可视化.
  1. I need to use the FIFOqueue to load training dataset as well as the validation dataset; The num_epoches for the training dataset is set to 10, but num_epoches for the validation dataset is set to 1 only, because in testing, we only need to run the whole validation dataset once.
  2. I need to test the network after several training steps with the validation dataset, not in a separate script using the checkpoint file saved by the training script;
  3. I need to store the loss, accuracy_validation data into a summary file, to visualize in Tensorboard.

然而,

  1. 发现每次运行代码sess.run(summary_op),其实都会触发输入数据的dequeue操作,这不是我所期望的.
  2. 并且,经过几个步骤后,我需要使用整个验证数据集来测试网络,而 sess.run(test_acc) 将只使用一批验证用于测试网络的数据集.
  1. I found that every time I run the code sess.run(summary_op), it actually would trigger a dequeue operation of the input data, which was not what I expected.
  2. And, after several steps, I need to test the network with the whole validation dataset, while sess.run(test_acc) will only use a batch of the validation dataset to test the network.

那么如何解决这两个问题呢?

So how to solve these two issues?

推荐答案

另一个解决方案是在训练操作的同时运行摘要操作.

Another solution is to run the summary op at the same time as the training operation.

_, loss_value, summary = sess.run([train_op, avg_loss, summary_op])

这样你只出队一次.

这篇关于Tensorflow:如何在不触发出队的情况下运行汇总操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆