Typically, we add summary when we train the network by using the following methods:
Tf.scalar_summary (tags, values)
#
... Summary_op = Tf.summary.merge_all ()
summary_writer = Tf.summary.FileWriter (LogDir, graph=sess.graph)
Summary_str = Sess.run (summary_op)
summary_writer.add_summary (Summary_str, Global_step)
When we want to add other data to the Tensorboard (such as the validation of the loss, etc.), this approach is too cumbersome, in fact, we can add custom data in the following way to display in Tensorboard.
Summary_writer = Tf.summary.FileWriter (logdir)
summary = tf. Summary (value=[
TF. Summary.value (tag= "Summary_tag", simple_value=0),
TF. Summary.value (tag= "Summary_tag2", simple_value=1),
])
# x represents the horizontal coordinate
summary_writer.add_summary (Summary, X
Or:
Summary_writer = Tf.summary.FileWriter (logdir)
summary = tf. Summary ()
summary.value.add (tag= "Summary_tag", simple_value=0)
Summary.value.add (tag= "Summary_tag2", simple_value=1)
# x represents the horizontal coordinate
summary_writer.add_summary (summary, X)
Note that the x here can only be an integer, and if it is a decimal, it automatically becomes an integer type.
Here's a complete sample code
Import TensorFlow as tf
summary_writer = tf.summary.FileWriter ('/tmp/test ')
summary = tf. Summary (value=[
TF. Summary.value (tag= "Summary_tag", simple_value=0),
TF. Summary.value (tag= "Summary_tag2", simple_value=1),
]
summary_writer.add_summary (Summary, 1)
Summary = TF. Summary (value=[
TF. Summary.value (tag= "Summary_tag", simple_value=1),
TF. Summary.value (tag= "Summary_tag2", simple_value=3),
])
summary_writer.add_summary (Summary, 2)
Summary_writer.close ()
The display effect looks like this:
Resources:
How to manually create a TF. Summary
Modify History:
2017-2-19 accomodation 1.0api