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


Python tensorflow.Event方法代碼示例

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


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

示例1: _setup_graph

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def _setup_graph(self):
        # special heuristics for Horovod
        from ..train import HorovodTrainer
        if isinstance(self.trainer, HorovodTrainer):
            if self.trainer.mpi_enabled():
                logger.warn("GPUUtilizationTracker is disabled under MPI.")
                self._enabled = False
                return
            else:
                self._devices = [self.trainer.hvd.local_rank()]

        if self._devices is None:
            self._devices = self._guess_devices()
        assert len(self._devices), "[GPUUtilizationTracker] No GPU device given!"

        self._evt = mp.Event()
        self._stop_evt = mp.Event()
        self._queue = mp.Queue()
        self._proc = mp.Process(target=self.worker, args=(
            self._evt, self._queue, self._stop_evt, self._devices))
        ensure_proc_terminate(self._proc)
        start_proc_mask_signal(self._proc) 
開發者ID:junsukchoe,項目名稱:ADL,代碼行數:24,代碼來源:prof.py

示例2: on_graph_def

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def on_graph_def(self, graph_def, device_name, wall_time):
        """Implementation of the GraphDef-carrying Event proto callback.

        Args:
          graph_def: A GraphDef proto. N.B.: The GraphDef is from
            the core runtime of a debugged Session::Run() call, after graph
            partition. Therefore it may differ from the GraphDef available to
            the general TensorBoard. For example, the GraphDef in general
            TensorBoard may get partitioned for multiple devices (CPUs and GPUs),
            each of which will generate a GraphDef event proto sent to this
            method.
          device_name: Name of the device on which the graph was created.
          wall_time: An epoch timestamp (in microseconds) for the graph.
        """
        # For now, we do nothing with the graph def. However, we must define this
        # method to satisfy the handler's interface. Furthermore, we may use the
        # graph in the future (for instance to provide a graph if there is no graph
        # provided otherwise).
        del wall_time
        self._graph_defs[device_name] = graph_def

        if not self._graph_defs_arrive_first:
            self._add_graph_def(device_name, graph_def)
            self._incoming_channel.get() 
開發者ID:tensorflow,項目名稱:tensorboard,代碼行數:26,代碼來源:interactive_debugger_server_lib.py

示例3: tb_add_histogram

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def tb_add_histogram(experiment, name, wall_time, step, histo):
  # Tensorflow does not support key being unicode
  histo_string = {}
  for k,v in histo.items():
    histo_string[str(k)] = v
  histo = histo_string

  writer = tb_get_xp_writer(experiment)
  summary = tf.Summary(value=[
      tf.Summary.Value(tag=name, histo=histo),
  ])
  event = tf.Event(wall_time=wall_time, step=step, summary=summary)
  writer.add_event(event)
  writer.flush()
  tb_modified_xp(experiment, modified_type="histograms", wall_time=wall_time)

# Perform requests to tensorboard http api 
開發者ID:torrvision,項目名稱:crayon,代碼行數:19,代碼來源:server.py

示例4: Load

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def Load(self):
    """Loads all new values from disk.

    Calling Load multiple times in a row will not 'drop' events as long as the
    return value is not iterated over.

    Yields:
      All values that were written to disk that have not been yielded yet.
    """
    tf.logging.debug('Loading events from %s', self._file_path)
    while True:
      try:
        with tf.errors.raise_exception_on_not_ok_status() as status:
          self._reader.GetNext(status)
      except (tf.errors.DataLossError, tf.errors.OutOfRangeError):
        # We ignore partial read exceptions, because a record may be truncated.
        # PyRecordReader holds the offset prior to the failed read, so retrying
        # will succeed.
        break
      event = tf.Event()
      event.ParseFromString(self._reader.record())
      yield event
    tf.logging.debug('No more events in %s', self._file_path) 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:25,代碼來源:event_file_loader.py

示例5: on_graph_def

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def on_graph_def(self, graph_def, device_name, wall_time):
    """Implementation of the GraphDef-carrying Event proto callback.

    Args:
      graph_def: A GraphDef proto. N.B.: The GraphDef is from
        the core runtime of a debugged Session::Run() call, after graph
        partition. Therefore it may differ from the GraphDef available to
        the general TensorBoard. For example, the GraphDef in general
        TensorBoard may get partitioned for multiple devices (CPUs and GPUs),
        each of which will generate a GraphDef event proto sent to this
        method.
      device_name: Name of the device on which the graph was created.
      wall_time: An epoch timestamp (in microseconds) for the graph.
    """
    # For now, we do nothing with the graph def. However, we must define this
    # method to satisfy the handler's interface. Furthermore, we may use the
    # graph in the future (for instance to provide a graph if there is no graph
    # provided otherwise).
    del device_name
    del wall_time
    del graph_def 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:23,代碼來源:debugger_server_lib.py

示例6: WriteScalarSeries

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def WriteScalarSeries(writer, tag, f, n=5):
  """Write a series of scalar events to writer, using f to create values."""
  step = 0
  wall_time = _start_time
  for i in xrange(n):
    v = f(i)
    value = tf.Summary.Value(tag=tag, simple_value=v)
    summary = tf.Summary(value=[value])
    event = tf.Event(wall_time=wall_time, step=step, summary=summary)
    writer.add_event(event)
    step += 1
    wall_time += 10 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:generate_testdata.py

示例7: WriteHistogramSeries

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def WriteHistogramSeries(writer, tag, mu_sigma_tuples, n=20):
  """Write a sequence of normally distributed histograms to writer."""
  step = 0
  wall_time = _start_time
  for [mean, stddev] in mu_sigma_tuples:
    data = [random.normalvariate(mean, stddev) for _ in xrange(n)]
    histo = _MakeHistogram(data)
    summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=histo)])
    event = tf.Event(wall_time=wall_time, step=step, summary=summary)
    writer.add_event(event)
    step += 10
    wall_time += 100 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:generate_testdata.py

示例8: _before_train

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def _before_train(self):
        assert gpu_available_in_session(), "[GPUUtilizationTracker] needs GPU!"
        self._evt = mp.Event()
        self._stop_evt = mp.Event()
        self._queue = mp.Queue()
        self._proc = mp.Process(target=self.worker, args=(
            self._evt, self._queue, self._stop_evt))
        ensure_proc_terminate(self._proc)
        start_proc_mask_signal(self._proc) 
開發者ID:microsoft,項目名稱:petridishnn,代碼行數:11,代碼來源:prof.py

示例9: _write_event

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def _write_event(self, metadata):
        evt = tf.Event()
        evt.tagged_run_metadata.tag = 'trace-{}'.format(self.global_step)
        evt.tagged_run_metadata.run_metadata = metadata.SerializeToString()
        self.trainer.monitors.put_event(evt) 
開發者ID:microsoft,項目名稱:petridishnn,代碼行數:7,代碼來源:prof.py

示例10: WriteScalarSeries

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def WriteScalarSeries(writer, tag, f, n=5):
    """Write a series of scalar events to writer, using f to create values."""
    step = 0
    wall_time = _start_time
    for i in xrange(n):
        v = f(i)
        value = tf.Summary.Value(tag=tag, simple_value=v)
        summary = tf.Summary(value=[value])
        event = tf.Event(wall_time=wall_time, step=step, summary=summary)
        writer.add_event(event)
        step += 1
        wall_time += 10 
開發者ID:tensorflow,項目名稱:tensorboard,代碼行數:14,代碼來源:generate_testdata.py

示例11: WriteHistogramSeries

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def WriteHistogramSeries(writer, tag, mu_sigma_tuples, n=20):
    """Write a sequence of normally distributed histograms to writer."""
    step = 0
    wall_time = _start_time
    for [mean, stddev] in mu_sigma_tuples:
        data = [random.normalvariate(mean, stddev) for _ in xrange(n)]
        histo = _MakeHistogram(data)
        summary = tf.Summary(value=[tf.Summary.Value(tag=tag, histo=histo)])
        event = tf.Event(wall_time=wall_time, step=step, summary=summary)
        writer.add_event(event)
        step += 10
        wall_time += 100 
開發者ID:tensorflow,項目名稱:tensorboard,代碼行數:14,代碼來源:generate_testdata.py

示例12: _extract_device_name_from_event

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def _extract_device_name_from_event(event):
    """Extract device name from a tf.Event proto carrying tensor value."""
    plugin_data_content = json.loads(
        tf.compat.as_str(event.summary.value[0].metadata.plugin_data.content)
    )
    return plugin_data_content["device"] 
開發者ID:tensorflow,項目名稱:tensorboard,代碼行數:8,代碼來源:interactive_debugger_server_lib.py

示例13: on_core_metadata_event

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def on_core_metadata_event(self, event):
        """Implementation of the core metadata-carrying Event proto callback.

        Args:
          event: An Event proto that contains core metadata about the debugged
            Session::Run() in its log_message.message field, as a JSON string.
            See the doc string of debug_data.DebugDumpDir.core_metadata for details.
        """
        core_metadata = json.loads(event.log_message.message)
        input_names = ",".join(core_metadata["input_names"])
        output_names = ",".join(core_metadata["output_names"])
        target_nodes = ",".join(core_metadata["target_nodes"])

        self._run_key = RunKey(input_names, output_names, target_nodes)
        if not self._graph_defs:
            self._graph_defs_arrive_first = False
        else:
            for device_name in self._graph_defs:
                self._add_graph_def(device_name, self._graph_defs[device_name])

        self._outgoing_channel.put(
            _comm_metadata(self._run_key, event.wall_time)
        )

        # Wait for acknowledgement from client. Blocks until an item is got.
        logger.info("on_core_metadata_event() waiting for client ack (meta)...")
        self._incoming_channel.get()
        logger.info("on_core_metadata_event() client ack received (meta).")

        # TODO(cais): If eager mode, this should return something to yield. 
開發者ID:tensorflow,項目名稱:tensorboard,代碼行數:32,代碼來源:interactive_debugger_server_lib.py

示例14: _CreateEventWithDebugNumericSummary

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def _CreateEventWithDebugNumericSummary(
        self, device_name, op_name, output_slot, wall_time, step, list_of_values
    ):
        """Creates event with a health pill summary.

        Note the debugger plugin only works with TensorFlow and, thus, uses TF
        protos and TF EventsWriter.

        Args:
          device_name: The name of the op's device.
          op_name: The name of the op to which a DebugNumericSummary was attached.
          output_slot: The numeric output slot for the tensor.
          wall_time: The numeric wall time of the event.
          step: The step of the event.
          list_of_values: A python list of values within the tensor.

        Returns:
          A `tf.Event` with a health pill summary.
        """
        event = tf.compat.v1.Event(step=step, wall_time=wall_time)
        tensor = tf.compat.v1.make_tensor_proto(
            list_of_values, dtype=tf.float64, shape=[len(list_of_values)]
        )
        value = event.summary.value.add(
            tag=op_name,
            node_name="%s:%d:DebugNumericSummary" % (op_name, output_slot),
            tensor=tensor,
        )
        content_proto = debugger_event_metadata_pb2.DebuggerEventMetadata(
            device=device_name, output_slot=output_slot
        )
        value.metadata.plugin_data.plugin_name = constants.DEBUGGER_PLUGIN_NAME
        value.metadata.plugin_data.content = tf.compat.as_bytes(
            json_format.MessageToJson(
                content_proto, including_default_value_fields=True
            )
        )
        return event 
開發者ID:tensorflow,項目名稱:tensorboard,代碼行數:40,代碼來源:debugger_plugin_testlib.py

示例15: tb_add_scalar

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import Event [as 別名]
def tb_add_scalar(experiment, name, wall_time, step, value):
  writer = tb_get_xp_writer(experiment)
  summary = tf.Summary(value=[
      tf.Summary.Value(tag=name, simple_value=value),
  ])
  event = tf.Event(wall_time=wall_time, step=step, summary=summary)
  writer.add_event(event)
  writer.flush()
  tb_modified_xp(experiment, modified_type="scalars", wall_time=wall_time) 
開發者ID:torrvision,項目名稱:crayon,代碼行數:11,代碼來源:server.py


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