【问题标题】:How to use several summary collections in Tensorflow?如何在 Tensorflow 中使用几个汇总集合?
【发布时间】:2016-11-21 14:23:29
【问题描述】:

我有 2 组独特的摘要。每批次收集一次,每个时期收集一次。如何使用merge_all_summaries(key='???') 分别收集这两组的摘要?手动操作始终是一种选择,但似乎有更好的方法。

说明我认为它应该如何工作:

      # once per batch 
      tf.scalar_summary("loss", graph.loss)
      tf.scalar_summary("batch_acc", batch_accuracy)
      # once per epoch
      gradients = tf.gradients(graph.loss, [W, D])
      tf.histogram_summary("embedding/W", W, collections='per_epoch')
      tf.histogram_summary("embedding/D", D, collections='per_epoch')

      tf.merge_all_summaries()                # -> (MergeSummary...) :)
      tf.merge_all_summaries(key='per_epoch') # -> NONE              :(

【问题讨论】:

  • 首先找到了这个问题,但搜索了 2 个没有区别的摘要组。这种方法stackoverflow.com/questions/42418029/… 对于稍微不同的用例来说更容易一些。您可以简单地使用摘要的名称。

标签: python tensorflow summary


【解决方案1】:

问题解决了。 collections 摘要的参数应该是一个列表。 解决方案:

  # once per batch 
  tf.scalar_summary("loss", graph.loss)
  tf.scalar_summary("batch_acc", batch_accuracy)
  # once per epoch
  tf.histogram_summary("embedding/W", W, collections=['per_epoch'])
  tf.histogram_summary("embedding/D", D, collections=['per_epoch'])

  tf.merge_all_summaries()                # -> (MergeSummary...) :)
  tf.merge_all_summaries(key='per_epoch') # -> (MergeSummary...) :)

编辑。 TF 中的句法变化:

# once per batch 
  tf.summary.scalar("loss", graph.loss)
  tf.summary.scalar("batch_acc", batch_accuracy)
  # once per epoch
  tf.summary.histogram("embedding/W", W, collections=['per_epoch'])
  tf.summary.histogram("embedding/D", D, collections=['per_epoch'])

  tf.summary.merge_all()                # -> (MergeSummary...) :)
  tf.summary.merge_all(key='per_epoch') # -> (MergeSummary...) :)

【讨论】:

    猜你喜欢
    • 2012-07-03
    • 2020-10-25
    • 1970-01-01
    • 2017-06-28
    • 2021-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    相关资源
    最近更新 更多