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


Python Summary.Value方法代碼示例

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


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

示例1: run_loop

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def run_loop(self):
    # Count the steps.
    current_step = training_util.global_step(self._sess, self._step_counter)
    added_steps = current_step - self._last_step
    self._last_step = current_step
    # Measure the elapsed time.
    current_time = time.time()
    elapsed_time = current_time - self._last_time
    self._last_time = current_time
    # Reports the number of steps done per second
    if elapsed_time > 0.:
      steps_per_sec = added_steps / elapsed_time
    else:
      steps_per_sec = float("inf")
    summary = Summary(value=[Summary.Value(tag=self._summary_tag,
                                           simple_value=steps_per_sec)])
    if self._sv.summary_writer:
      self._sv.summary_writer.add_summary(summary, current_step)
    logging.log_first_n(logging.INFO, "%s: %g", 10,
                        self._summary_tag, steps_per_sec) 
開發者ID:yuantailing,項目名稱:ctw-baseline,代碼行數:22,代碼來源:supervisor.py

示例2: run_loop

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def run_loop(self):
    # Count the steps.
    current_step = training_util.global_step(self._sess, self._sv.global_step)
    added_steps = current_step - self._last_step
    self._last_step = current_step
    # Measure the elapsed time.
    current_time = time.time()
    elapsed_time = current_time - self._last_time
    self._last_time = current_time
    # Reports the number of steps done per second
    steps_per_sec = added_steps / elapsed_time
    summary = Summary(value=[Summary.Value(tag=self._summary_tag,
                                           simple_value=steps_per_sec)])
    if self._sv.summary_writer:
      self._sv.summary_writer.add_summary(summary, current_step)
    logging.log_first_n(logging.INFO, "%s: %g", 10,
                        self._summary_tag, steps_per_sec) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:19,代碼來源:supervisor.py

示例3: scalar

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def scalar(name, scalar):
    """Outputs a `Summary` protocol buffer containing a single scalar value.
    The generated Summary has a Tensor.proto containing the input Tensor.
    Args:
      name: A name for the generated node. Will also serve as the series name in
        TensorBoard.
      scalar: A real numeric Tensor containing a single value.
      collections: Optional list of graph collections keys. The new summary op is
        added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
    Returns:
      A scalar `Tensor` of type `string`. Which contains a `Summary` protobuf.
    Raises:
      ValueError: If tensor has the wrong shape or type.
    """
    name = _clean_tag(name)
    if not isinstance(scalar, float):
        # try conversion, if failed then need handle by user.
        scalar = float(scalar)
    return Summary(value=[Summary.Value(tag=name, simple_value=scalar)]) 
開發者ID:NervanaSystems,項目名稱:ngraph-python,代碼行數:21,代碼來源:summary.py

示例4: histogram

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def histogram(name, values):
    # pylint: disable=line-too-long
    """Outputs a `Summary` protocol buffer with a histogram.
    The generated
    [`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
    has one summary value containing a histogram for `values`.
    This op reports an `InvalidArgument` error if any value is not finite.
    Args:
      name: A name for the generated node. Will also serve as a series name in
        TensorBoard.
      values: A real numeric `Tensor`. Any shape. Values to use to
        build the histogram.
    Returns:
      A scalar `Tensor` of type `string`. The serialized `Summary` protocol
      buffer.
    """
    name = _clean_tag(name)
    hist = make_histogram(values.astype(float))
    return Summary(value=[Summary.Value(tag=name, histo=hist)]) 
開發者ID:NervanaSystems,項目名稱:ngraph-python,代碼行數:21,代碼來源:summary.py

示例5: audio

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def audio(tag, tensor, sample_rate):
    """Outputs a `Summary` protocol buffer with audio.
    The audio is built from `tensor` which must be 2-D with shape `[num_frames,
    channels]`.
    Args:
      tag: A name for the generated node. Will also serve as a series name in
        TensorBoard.
      tensor: A 2-D `int16` `Tensor` of shape `[num_frames, channels]`
      sample_rate: An `int` declaring the sample rate for the provided audio
    Returns:
      A scalar `Tensor` of type `string`. The serialized `Summary` protocol
      buffer.
    """
    tag = _clean_tag(tag)
    if len(tensor.shape) == 1:
        num_frames, num_channels = len(tensor), 1
    elif len(tensor.shape) == 2:
        num_frames, num_channels = tensor.shape
    else:
        raise ValueError("audio must have 1 or 2 dimensions, not {}".format(len(tensor.shape)))

    tensor = make_audio(tensor, sample_rate, num_frames, num_channels)
    return Summary(value=[Summary.Value(tag=tag, audio=tensor)]) 
開發者ID:NervanaSystems,項目名稱:ngraph-python,代碼行數:25,代碼來源:summary.py

示例6: after_run

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def after_run(self, run_context, run_values):
    _ = run_context

    stale_global_step = run_values.results
    if self._timer.should_trigger_for_step(stale_global_step+1):
      # get the real value after train op.
      global_step = run_context.session.run(self._global_step_tensor)
      if self._timer.should_trigger_for_step(global_step):
        elapsed_time, elapsed_steps = self._timer.update_last_triggered_step(
            global_step)
        if elapsed_time is not None:
          steps_per_sec = elapsed_steps / elapsed_time
          if self._summary_writer is not None:
            summary = Summary(value=[Summary.Value(
                tag=self._summary_tag, simple_value=steps_per_sec)])
            self._summary_writer.add_summary(summary, global_step)
          logging.info("%s: %g", self._summary_tag, steps_per_sec) 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:19,代碼來源:basic_session_run_hooks.py

示例7: write_summary

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def write_summary(summary_writer, label, value, step):
  """Write a summary for a certain evaluation."""
  summary = Summary(value=[Summary.Value(tag=label, simple_value=float(value))])
  summary_writer.add_summary(summary, step)
  summary_writer.flush() 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:7,代碼來源:trainer_lib.py

示例8: after_run

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def after_run(self, run_context, run_values):
    _ = run_context

    global_step = run_values.results
    if self._timer.should_trigger_for_step(global_step):
      elapsed_time, elapsed_steps = self._timer.update_last_triggered_step(
          global_step)
      if elapsed_time is not None:
        steps_per_sec = elapsed_steps / elapsed_time
        if self._summary_writer is not None:
          summary = Summary(value=[Summary.Value(
              tag=self._summary_tag, simple_value=steps_per_sec)])
          self._summary_writer.add_summary(summary, global_step)
        logging.info("%s: %g", self._summary_tag, steps_per_sec) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:16,代碼來源:basic_session_run_hooks.py

示例9: every_n_step_end

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def every_n_step_end(self, current_step, outputs):
    current_time = time.time()
    if self._last_reported_time is not None and self._summary_writer:
      added_steps = current_step - self._last_reported_step
      elapsed_time = current_time - self._last_reported_time
      steps_per_sec = added_steps / elapsed_time
      summary = Summary(value=[Summary.Value(tag=self._summary_tag,
                                             simple_value=steps_per_sec)])
      self._summary_writer.add_summary(summary, current_step)
    self._last_reported_step = current_step
    self._last_reported_time = current_time 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:13,代碼來源:monitors.py

示例10: image

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def image(tag, tensor):
    """Outputs a `Summary` protocol buffer with images.
    The summary has up to `max_images` summary values containing images. The
    images are built from `tensor` which must be 3-D with shape `[height, width,
    channels]` and where `channels` can be:
    *  1: `tensor` is interpreted as Grayscale.
    *  3: `tensor` is interpreted as RGB.
    *  4: `tensor` is interpreted as RGBA.
    The `name` in the outputted Summary.Value protobufs is generated based on the
    name, with a suffix depending on the max_outputs setting:
    *  If `max_outputs` is 1, the summary value tag is '*name*/image'.
    *  If `max_outputs` is greater than 1, the summary value tags are
       generated sequentially as '*name*/image/0', '*name*/image/1', etc.
    Args:
      tag: A name for the generated node. Will also serve as a series name in
        TensorBoard.
      tensor: A 3-D `uint8` or `float32` `Tensor` of shape `[height, width,
        channels]` where `channels` is 1, 3, or 4.
    Returns:
      A scalar `Tensor` of type `string`. The serialized `Summary` protocol
      buffer.
    """
    tag = _clean_tag(tag)
    if not isinstance(tensor, np.ndarray):
        # try conversion, if failed then need handle by user.
        tensor = np.ndarray(tensor, dtype=np.float32)
    shape = tensor.shape
    height, width, channel = shape[0], shape[1], shape[2]
    if channel == 1:
        # walk around. PIL's setting on dimension.
        tensor = np.reshape(tensor, (height, width))
    image = make_image(tensor, height, width, channel)
    return Summary(value=[Summary.Value(tag=tag, image=image)]) 
開發者ID:NervanaSystems,項目名稱:ngraph-python,代碼行數:35,代碼來源:summary.py

示例11: _log_and_record

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def _log_and_record(self, elapsed_steps, elapsed_time, global_step):
    global_step_per_sec = elapsed_steps / elapsed_time
    examples_per_sec = self._batch_size * global_step_per_sec
    if self._summary_writer is not None:
      global_step_summary = Summary(value=[
          Summary.Value(tag='global_step/sec', simple_value=global_step_per_sec)
      ])
      example_summary = Summary(value=[
          Summary.Value(tag='examples/sec', simple_value=examples_per_sec)
      ])
      self._summary_writer.add_summary(global_step_summary, global_step)
      self._summary_writer.add_summary(example_summary, global_step)
    logging.info('global_step/sec: %g', global_step_per_sec)
    logging.info('examples/sec: %g', examples_per_sec) 
開發者ID:ymcui,項目名稱:Chinese-XLNet,代碼行數:16,代碼來源:tpu_estimator.py

示例12: write_hptuning_metric

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def write_hptuning_metric(args, metric):
  """
  Write a summary containing the tuning loss metric, as required by hyperparam tuning.
  """
  summary = Summary(value=[Summary.Value(tag='training/hptuning/metric', simple_value=metric)])

  # for hyperparam tuning, we write a summary log to a directory 'eval' below the job directory
  eval_path = os.path.join(args['output_dir'], 'eval')
  summary_writer = tf.summary.FileWriter(eval_path)

  # Note: adding the summary to the writer is enough for hyperparam tuning.
  # The ml engine system is looking for any summary added with the hyperparam metric tag.
  summary_writer.add_summary(summary)
  summary_writer.flush() 
開發者ID:GoogleCloudPlatform,項目名稱:tensorflow-recommendation-wals,代碼行數:16,代碼來源:util.py

示例13: add_summary

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def add_summary(self, summary_tag, summary_value, global_step):
        """ Adds summary at specific step.

        Args:
            summary_tag: A string, the name of the summary.
            summary_value: The value of the summary at current step.
            global_step: The step.
        """
        summary = Summary(value=[Summary.Value(
            tag=summary_tag, simple_value=summary_value)])
        self._summary_writer.add_summary(summary, global_step)
        self._summary_writer.flush() 
開發者ID:zhaocq-nlp,項目名稱:NJUNMT-tf,代碼行數:14,代碼來源:summary_writer.py

示例14: add_entry

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def add_entry(self, index, tag, value, **kwargs):
        if "image" in kwargs and value is not None:
            image_string = tf.image.encode_jpeg(value, optimize_size=True, quality=80)
            summary_value = Summary.Image(width=value.shape[1],
                                          height=value.shape[0],
                                          colorspace=value.shape[2],
                                          encoded_image_string=image_string)
        else:
            summary_value = Summary.Value(tag=tag, simple_value=value)

        if summary_value is not None:
            entry = Summary(value=[summary_value])
            self._train_writer.add_summary(entry, index) 
開發者ID:microsoft,項目名稱:malmo-challenge,代碼行數:15,代碼來源:tensorboard.py

示例15: tf_scalar_summary

# 需要導入模塊: from tensorflow.core.framework.summary_pb2 import Summary [as 別名]
# 或者: from tensorflow.core.framework.summary_pb2.Summary import Value [as 別名]
def tf_scalar_summary(vals):
    # pylint: disable=import-error,no-name-in-module
    from tensorflow.core.framework.summary_pb2 import Summary

    return Summary(
        value=[Summary.Value(tag=key, simple_value=val) for key, val in vals.items()]
    ) 
開發者ID:guildai,項目名稱:guildai,代碼行數:9,代碼來源:summary_util.py


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