I want to log some arbitrary strings in TensorBoard.
I know how to do it for arbitrary scalars:
from tensorflow.core.framework import summary_pb2
value = summary_pb2.Summary.Value(tag='Accuracy', simple_value=0.95)
my_summary = summary_pb2.Summary(value=[value])
summary_writer = tf.summary.FileWriter()
summary_writer.add_summary(summary)
But how to do the same thing but for arbitrary text summary?
Something like (which doesn't exist):
value = summary_pb2.Summary.Text(tag='MyTag', str='Arbitrary text come here')
UPD: Note that I provided an example how to create an arbitrary scalar summary without calling session.run(...)
. I want to be able to do it for text as well.
The tf. summary module provides APIs for writing summary data. This data can be visualized in TensorBoard, the visualization toolkit that comes with TensorFlow. See the TensorBoard website for more detailed tutorials about how to use these APIs, or some quick examples below.
Overview. Using the TensorFlow Text Summary API, you can easily log arbitrary text and view it in TensorBoard. This can be extremely helpful to sample and examine your input data, or to record execution metadata or generated text.
I have been searching for an answer, too. Peeking at some source code for TensorFlow/Board, I found a way which seems to work (I don't know whether a simpler solution exists).
value = "Random text"
text_tensor = tf.make_tensor_proto(value, dtype=tf.string)
meta = tf.SummaryMetadata()
meta.plugin_data.plugin_name = "text"
summary = tf.Summary()
summary.value.add(tag="whatever", metadata=meta, tensor=text_tensor)
summary_writer.add_summary(summary)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With