问题描述
限时送ChatGPT账号..我经常想记录 python 变量——而不是 tf 张量.
I often want to log python variables --as opposed to tf tensors.
在文档中它说你可以传递一个 tf.Summary
协议缓冲区,用你自己的数据填充"但没有 tf.Summary
的文档我不知道如何使用它.
In the docs it says that "you can pass a tf.Summary
protocol buffer that you populate with your own data" but there is no docs for tf.Summary
and i could not figure out how to use it.
有人知道如何以这种方式创建标量摘要吗?
Anyone knows how to create a Scalar summary this way?
推荐答案
你可以在你的 Python 程序中创建一个 tf.Summary
对象并将其写入同一个 tf.summary.FileWriter
对象,它使用 tf.summary.FileWriter
对象获取 TensorFlow 生成的摘要一个 href="https://www.tensorflow/api_docs/python/tf/summary/FileWriter#add_summary" rel="noreferrer">SummaryWriter.add_summary()
方法.
You can create a tf.Summary
object in your Python program and write it to the same tf.summary.FileWriter
object that takes your TensorFlow-produced summaries using the SummaryWriter.add_summary()
method.
tf.Summary
类是一个 Python 协议缓冲区包装器,用于总结
协议缓冲区.每个 Summary
都包含一个 tf.Summary.Value
协议缓冲区,每个都有一个标签和一个简单"(浮点标量)值,一个 图像,直方图,或音频片段.例如,您可以从 Python 对象生成一个标量摘要,如下所示:
The tf.Summary
class is a Python protocol buffer wrapper for the Summary
protocol buffer. Each Summary
contains a list of tf.Summary.Value
protocol buffers, which each have a tag and a either a "simple" (floating-point scalar) value, an image, a histogram, or an audio snippet. For example, you can generate a scalar summary from a Python object as follows:
writer = tf.train.SummaryWriter(...)
value = 37.0
summary = tf.Summary(value=[
tf.Summary.Value(tag="summary_tag", simple_value=value),
])
writer.add_summary(summary)
这篇关于如何手动创建 tf.Summary()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论