如何在 TensorFlow 中手动创建文本摘要?

How to manually create text summaries in TensorFlow?

首先,我已经知道如何手动添加浮动或图像摘要。我可以手动构造一个 tf.Summary protobuf。但是文本摘要呢?我查看了 summary protobuf here 的定义,但我在那里找不到 "string" 值选项。

TensorBoard 的文本插件提供了一种 pb 方法,可让您在 TensorFlow 环境之外创建文本摘要。 https://github.com/tensorflow/tensorboard/blob/master/tensorboard/plugins/text/summary.py#L74

用法示例:

import tensorboard as tb
text_summary_proto = tb.summary.pb('fooTag', 'text data')

John Hoffman 的回答很好,尽管 tb.summary.pb API 似乎从 TF 1.x 开始不可用。您可以改为使用以下 APIs:

tb.summary.text_pb("key", "content of the text data")

仅供参考,tb.summary 对于其他类型的摘要也有许多类似的方法:

'audio', audio_pb',
'custom_scalar', 'custom_scalar_pb',
'histogram', 'histogram_pb',
'image', 'image_pb',
'pr_curve', 'pr_curve_pb',
'pr_curve_raw_data_op',
'pr_curve_raw_data_pb',
'pr_curve_streaming_op',
'scalar', 'scalar_pb',
'text', 'text_pb'