o
    ?e                     @   sP   d Z ddlmZ ddlmZ ddlmZ G dd deZedgdd	d
 Z	dS )zHProvides a method for reading events from an event file via an iterator.    )	event_pb2)	tf_record)	tf_exportc                   @   s,   e Zd ZdZdd Zdd Zdd ZeZdS )	_SummaryIteratorz2Yields `Event` protocol buffers from a given path.c                 C   s   t || _d S N)r   Ztf_record_iterator_tf_record_iterator)selfpath r
   k/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/summary/summary_iterator.py__init__   s   z_SummaryIterator.__init__c                 C   s   | S r   r
   )r   r
   r
   r   __iter__   s   z_SummaryIterator.__iter__c                 C   s   t | j}tj|S r   )nextr   r   EventZ
FromString)r   rr
   r
   r   __next__    s   
z_SummaryIterator.__next__N)__name__
__module____qualname____doc__r   r   r   r   r
   r
   r
   r   r      s    r   ztrain.summary_iterator)v1c                 C   s   t | S )a  Returns a iterator for reading `Event` protocol buffers from an event file.

  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.

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

  Example: Print selected summary values.

  ```python
  # 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.

  ```python
  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.

  Args:
    path: The path to an event file created by a `SummaryWriter`.

  Returns:
    A iterator that yields `Event` protocol buffers
  )r   )r	   r
   r
   r   summary_iterator'   s   4r   N)
r   Ztensorflow.core.utilr   Ztensorflow.python.lib.ior   Z tensorflow.python.util.tf_exportr   objectr   r   r
   r
   r
   r   <module>   s   
