How to manually create a tf.Summary()

How to manually create a tf.Summary()

Asked on December 27, 2018 in Tensorflow.
Add Comment

  • 3 Answer(s)

          First create a tf.Summary object in Python program next write it to the same tf.summary.FileWriter object and by using the SummaryWriter.add_summary() method it takes the TensorFlow-produced summaries.

          For Summary protocol buffer the tf.Summary class is a Python protocol buffer wrapper. It contains a list of tf.Summary.Value protocol buffers for Each Summary, Each have a tag or a “simple” value, an image, a histogram, or an audio snippet.

    Example to generate a scalar summary from a Python object:

    writer = tf.train.SummaryWriter(...)
    value = 37.0
    summary = tf.Summary(value=[
        tf.Summary.Value(tag="summary_tag", simple_value=value),
    Answered on December 27, 2018.
    Add Comment

          Create a placeholder to log a python value this have to be fed while running the tf.Summary op.


    value_ = tf.placeholder(tf.float32, [])
    summary_op = tf.scalar_summary("value_log", value_)
    my_python_variable = 10
    # define everything else you need...
    # ...
    with tf.Session() as sess:
        for i in range(0, 10):
  , feed_dict={value_: my_python_variable*i})


    Answered on December 27, 2018.
    Add Comment

    Try this code loop before:

    writer = tf.summary.FileWriter(log_folder)
    accuracy = None
    accuracy_summary = tf.Summary()
    accuracy_summary.value.add(tag='accuracy', simple_value=accuracy)

    Loop Inside:

    if i%20000 == 0:
        accuracy = get_accuracy()
        accuracy_summary.value[0].simple_value = accuracy
        writer.add_summary(accuracy_summary, i)
    Answered on December 27, 2018.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.