Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I construct an arbitrary text summary in TensorFlow?

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.

like image 306
Temak Avatar asked Sep 14 '17 13:09

Temak


People also ask

What is TensorFlow summary?

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.

Can we check metadata of model in TensorBoard?

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.


1 Answers

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)
like image 85
rrobby86 Avatar answered Dec 09 '22 14:12

rrobby86