當前位置: 首頁>>代碼示例>>Python>>正文


Python pywrap_tensorflow.EventsWriter方法代碼示例

本文整理匯總了Python中tensorflow.python.pywrap_tensorflow.EventsWriter方法的典型用法代碼示例。如果您正苦於以下問題:Python pywrap_tensorflow.EventsWriter方法的具體用法?Python pywrap_tensorflow.EventsWriter怎麽用?Python pywrap_tensorflow.EventsWriter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.pywrap_tensorflow的用法示例。


在下文中一共展示了pywrap_tensorflow.EventsWriter方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, dir):
        try:
            os.makedirs(dir)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
        self.dir = dir
        self.step = 1
        prefix = 'events'
        path = osp.join(osp.abspath(dir), prefix)
        import tensorflow as tf
        from tensorflow.python import pywrap_tensorflow        
        from tensorflow.core.util import event_pb2
        from tensorflow.python.util import compat
        self.tf = tf
        self.event_pb2 = event_pb2
        self.pywrap_tensorflow = pywrap_tensorflow
        self.writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(path)) 
開發者ID:AdamStelmaszczyk,項目名稱:learning2run,代碼行數:20,代碼來源:logger.py

示例2: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, log_dir=None, writer=None):
        self.key_steps = {}
        self.rate_values = {}
        self.writer = None  # type: Union[None, pywrap_tensorflow.EventsWriter, tf.summary.FileWriter]

        if log_dir is None and writer is None:
            log_dir = 'logs'
            self.set_log_dir(log_dir)
        elif log_dir is not None and writer is None:
            self.set_log_dir(log_dir)
        elif log_dir is None and writer is not None:
            self.set_writer(writer)
        else:
            raise ValueError("Only one of log_dir or writer must be specified") 
開發者ID:mrahtz,項目名稱:easy-tf-log,代碼行數:16,代碼來源:easy_tf_log.py

示例3: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, dir):
        os.makedirs(dir, exist_ok=True)
        self.dir = dir
        self.step = 1
        prefix = 'events'
        path = osp.join(osp.abspath(dir), prefix)
        import tensorflow as tf
        from tensorflow.python import pywrap_tensorflow
        from tensorflow.core.util import event_pb2
        from tensorflow.python.util import compat
        self.tf = tf
        self.event_pb2 = event_pb2
        self.pywrap_tensorflow = pywrap_tensorflow
        self.writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(path)) 
開發者ID:Hwhitetooth,項目名稱:lirpg,代碼行數:16,代碼來源:logger.py

示例4: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, dir, prefix):
        self.dir = dir
        self.step = 1 # Start at 1, because EvWriter automatically generates an object with step=0
        self.evwriter = pywrap_tensorflow.EventsWriter(compat.as_bytes(os.path.join(dir, prefix))) 
開發者ID:openai,項目名稱:evolution-strategies-starter,代碼行數:6,代碼來源:tabular_logger.py

示例5: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, logdir, max_queue=10, flush_secs=120,
               filename_suffix=None):
    """Creates a `EventFileWriter` and an event file to write to.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers, which are written to
    disk via the add_event method.

    The other arguments to the constructor control the asynchronous writes to
    the event file:

    *  `flush_secs`: How often, in seconds, to flush the added summaries
       and events to disk.
    *  `max_queue`: Maximum number of summaries or events pending to be
       written to disk before one of the 'add' calls block.

    Args:
      logdir: A string. Directory where event file will be written.
      max_queue: Integer. Size of the queue for pending events and summaries.
      flush_secs: Number. How often, in seconds, to flush the
        pending events and summaries to disk.
      filename_suffix: A string. Every event file's name is suffixed with
        `filename_suffix`.
    """
    self._logdir = logdir
    if not gfile.IsDirectory(self._logdir):
      gfile.MakeDirs(self._logdir)
    self._event_queue = six.moves.queue.Queue(max_queue)
    self._ev_writer = pywrap_tensorflow.EventsWriter(
        compat.as_bytes(os.path.join(self._logdir, "events")))
    self._flush_secs = flush_secs
    self._sentinel_event = self._get_sentinel_event()
    if filename_suffix:
      self._ev_writer.InitWithSuffix(compat.as_bytes(filename_suffix))
    self._closed = False
    self._worker = _EventLoggerThread(self._event_queue, self._ev_writer,
                                      self._flush_secs, self._sentinel_event)

    self._worker.start() 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:41,代碼來源:event_file_writer.py

示例6: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, logdir, max_queue=10, flush_secs=120):
    """Creates a `EventFileWriter` and an event file to write to.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers, which are written to
    disk via the add_event method.

    The other arguments to the constructor control the asynchronous writes to
    the event file:

    *  `flush_secs`: How often, in seconds, to flush the added summaries
       and events to disk.
    *  `max_queue`: Maximum number of summaries or events pending to be
       written to disk before one of the 'add' calls block.

    Args:
      logdir: A string. Directory where event file will be written.
      max_queue: Integer. Size of the queue for pending events and summaries.
      flush_secs: Number. How often, in seconds, to flush the
        pending events and summaries to disk.
    """
    self._logdir = logdir
    if not gfile.IsDirectory(self._logdir):
      gfile.MakeDirs(self._logdir)
    self._event_queue = six.moves.queue.Queue(max_queue)
    self._ev_writer = pywrap_tensorflow.EventsWriter(
        compat.as_bytes(os.path.join(self._logdir, "events")))
    self._closed = False
    self._worker = _EventLoggerThread(self._event_queue, self._ev_writer,
                                      flush_secs)

    self._worker.start() 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:34,代碼來源:event_file_writer.py

示例7: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, folder):
        """
        Dumps key/value pairs into TensorBoard's numeric format.

        :param folder: (str) the folder to write the log to
        """
        os.makedirs(folder, exist_ok=True)
        self.dir = folder
        self.step = 1
        prefix = 'events'
        path = os.path.join(os.path.abspath(folder), prefix)
        self.writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(path))  # type: pywrap_tensorflow.EventsWriter 
開發者ID:Stable-Baselines-Team,項目名稱:stable-baselines,代碼行數:14,代碼來源:logger.py

示例8: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def __init__(self, dir):
        os.makedirs(dir, exist_ok=True)
        self.dir = dir
        self.step = 1
        prefix = 'events'
        path = osp.join(osp.abspath(dir), prefix)
        import tensorflow as tf
        from tensorflow.python import pywrap_tensorflow        
        from tensorflow.core.util import event_pb2
        from tensorflow.python.util import compat
        self.tf = tf
        self.event_pb2 = event_pb2
        self.pywrap_tensorflow = pywrap_tensorflow
        self.writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(path)) 
開發者ID:DartML,項目名稱:PPO-Stein-Control-Variate,代碼行數:16,代碼來源:tb_logger.py

示例9: testWriteEvents

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def testWriteEvents(self):
    file_prefix = os.path.join(self.get_temp_dir(), "events")
    writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(file_prefix))
    filename = compat.as_text(writer.FileName())
    event_written = event_pb2.Event(
        wall_time=123.45, step=67,
        summary=summary_pb2.Summary(
            value=[summary_pb2.Summary.Value(tag="foo", simple_value=89.0)]))
    writer.WriteEvent(event_written)
    writer.Flush()
    writer.Close()

    with self.assertRaises(errors.NotFoundError):
      for r in tf_record.tf_record_iterator(filename + "DOES_NOT_EXIST"):
        self.assertTrue(False)

    reader = tf_record.tf_record_iterator(filename)
    event_read = event_pb2.Event()

    event_read.ParseFromString(next(reader))
    self.assertTrue(event_read.HasField("file_version"))

    event_read.ParseFromString(next(reader))
    # Second event
    self.assertProtoEquals("""
    wall_time: 123.45 step: 67
    summary { value { tag: 'foo' simple_value: 89.0 } }
    """, event_read)

    with self.assertRaises(StopIteration):
      next(reader) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:33,代碼來源:events_writer_test.py

示例10: testWriteEventInvalidType

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def testWriteEventInvalidType(self):
    class _Invalid(object):
      def __str__(self): return "Invalid"
    with self.assertRaisesRegexp(TypeError, "Invalid"):
      pywrap_tensorflow.EventsWriter(b"foo").WriteEvent(_Invalid()) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:7,代碼來源:events_writer_test.py

示例11: set_log_dir

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import EventsWriter [as 別名]
def set_log_dir(self, log_dir):
        os.makedirs(log_dir, exist_ok=True)
        path = osp.join(log_dir, "events")
        # Why don't we just use an EventsFileWriter?
        # By default, we want to be fork-safe - we want to work even if we
        # create the writer in one process and try to use it in a forked
        # process. And because EventsFileWriter uses a subthread to do the
        # actual writing, EventsFileWriter /isn't/ fork-safe.
        self.writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(path)) 
開發者ID:mrahtz,項目名稱:easy-tf-log,代碼行數:11,代碼來源:easy_tf_log.py


注:本文中的tensorflow.python.pywrap_tensorflow.EventsWriter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。