tf.contrib.summary.generic 或 tf.summary.text 急切模式 [英] tf.contrib.summary.generic or tf.summary.text in eager mode

查看:34
本文介绍了tf.contrib.summary.generic 或 tf.summary.text 急切模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Eager 模式时,似乎只支持 tf.contrib.summary.scalar.是否有使用 tf.contrib.summary.generic 或 tf.summary.text 的解决方法?

It looks like only tf.contrib.summary.scalar is supported when using eager mode. Is there a workaround to use tf.contrib.summary.generic or tf.summary.text?

推荐答案

我相信你错了.所有 tf.contrib.summary 中的汇总方法都支持 Eager Execution 和图构建.例如,这样的事情似乎有效:

I believe you are mistaken. All the summary methods in tf.contrib.summary are supported for both eager execution and graph construction. For example, something like this seems to work:

import tensorflow as tf

tf.enable_eager_execution()

with tf.contrib.summary.create_file_writer('/tmp/logdir').as_default(), tf.contrib.summary.always_record_summaries():
  for step in range(3):
    tf.contrib.summary.generic("generic", tf.pow(10., step), step=step)
    tf.contrib.summary.histogram("histogram", tf.random_uniform([10]), step=step)
  tf.contrib.summary.flush()

使用 tensorboard --logdir/tmp/logdir --inspect 可以看到每个事件都写入了 3 个事件,当然也可以在 tensorboard 中可视化直方图.

With tensorboard --logdir /tmp/logdir --inspect you can see that 3 events each are written, and of course the histogram can be visualized in tensorboard.

希望有所帮助.

这篇关于tf.contrib.summary.generic 或 tf.summary.text 急切模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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