# tf.compat.v1.train.summary_iterator

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/summary/summary_iterator.py#L39-L91) |

Returns a iterator for reading `Event` protocol buffers from an event file.

    tf.compat.v1.train.summary_iterator(
        path
    )

You can use this function to read events written to an event file. It returns
a Python iterator that yields `Event` protocol buffers.

Example: Print the contents of an events file.

    for e in tf.compat.v1.train.summary_iterator(path to events file):
        print(e)

Example: Print selected summary values.

    # This example supposes that the events file contains summaries with a
    # summary value tag 'loss'.  These could have been added by calling
    # `add_summary()`, passing the output of a scalar summary op created with
    # with: `tf.compat.v1.summary.scalar('loss', loss_tensor)`.
    for e in tf.compat.v1.train.summary_iterator(path to events file):
        for v in e.summary.value:
            if v.tag == 'loss':
                print(tf.make_ndarray(v.tensor))

Example: Continuously check for new summary values.

    summaries = tf.compat.v1.train.summary_iterator(path to events file)
    while True:
      for e in summaries:
          for v in e.summary.value:
              if v.tag == 'loss':
                  print(tf.make_ndarray(v.tensor))
      # Wait for a bit before checking the file for any new events
      time.sleep(wait time)

See the protocol buffer definitions of
[Event](https://www.tensorflow.org/code/tensorflow/core/util/event.proto)
and
[Summary](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
for more information about their attributes.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `path` | The path to an event file created by a `SummaryWriter`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A iterator that yields `Event` protocol buffers ||

<br />