我对TensorFlow 1.x非常熟悉,并且正在考虑为即将进行的项目切换到TensorFlow 2。我在理解如何使用自定义训练循环,急切执行将标量写入TensorBoard日志时遇到一些麻烦。
在tf1中,您将创建一些摘要操作(每个要存储的操作一个操作),然后将其合并为一个操作,在会话中运行合并的操作,然后使用FileWriter对象将其写入文件。假设sess
是我们tf.Session()
,下面是一个如何工作的示例:
# While defining our computation graph, define summary ops:
# ... some ops ...
tf.summary.scalar('scalar_1', scalar_1)
# ... some more ops ...
tf.summary.scalar('scalar_2', scalar_2)
# ... etc.
# Merge all these summaries into a single op:
merged = tf.summary.merge_all()
# Define a FileWriter (i.e. an object that writes summaries to files):
writer = tf.summary.FileWriter(log_dir, sess.graph)
# Inside the training loop run the op and write the …
Run Code Online (Sandbox Code Playgroud) 在张量板中,我想在同一图表上叠加2个图(神经网络的训练和验证损失).
我可以看到2个单独的图,但不是一个有2条叠加曲线的图.否则,我得到一个曲折的情节.
我能怎么做?