当前位置: 首页>>代码示例>>Python>>正文


Python summary_pb2.Summary方法代码示例

本文整理汇总了Python中tensorflow.core.framework.summary_pb2.Summary方法的典型用法代码示例。如果您正苦于以下问题:Python summary_pb2.Summary方法的具体用法?Python summary_pb2.Summary怎么用?Python summary_pb2.Summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.core.framework.summary_pb2的用法示例。


在下文中一共展示了summary_pb2.Summary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def add_summary(self, summary, global_step=None):
    """Adds a `Summary` protocol buffer to the event file.

    This method wraps the provided summary in an `Event` protocol buffer
    and adds it to the event file.

    You can pass the result of evaluating any summary op, using
    @{tf.Session.run} or
    @{tf.Tensor.eval}, to this
    function. Alternatively, you can pass a `tf.Summary` protocol
    buffer that you populate with your own data. The latter is
    commonly done to report evaluation results in event files.

    Args:
      summary: A `Summary` protocol buffer, optionally serialized as a string.
      global_step: Number. Optional global step value to record with the
        summary.
    """
    if isinstance(summary, bytes):
      summ = summary_pb2.Summary()
      summ.ParseFromString(summary)
      summary = summ
    event = event_pb2.Event(summary=summary)
    self._add_event(event, global_step) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:writer.py

示例2: _write_summary_results

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def _write_summary_results(output_dir, eval_results, current_global_step):
  """Writes eval results into summary file in given dir."""
  logging.info('Saving evaluation summary for step %d: %s', current_global_step,
               _eval_results_to_str(eval_results))
  summary_writer = get_summary_writer(output_dir)
  summary = summary_pb2.Summary()
  for key in eval_results:
    if eval_results[key] is None:
      continue
    value = summary.value.add()
    value.tag = key
    if (isinstance(eval_results[key], np.float32) or
        isinstance(eval_results[key], float)):
      value.simple_value = float(eval_results[key])
    else:
      logging.warn('Skipping summary for %s, must be a float or np.float32.',
                   key)
  summary_writer.add_summary(summary, current_global_step)
  summary_writer.flush() 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:graph_actions.py

示例3: assert_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def assert_summary(expected_tags, expected_simple_values, summary_proto):
  """Asserts summary contains the specified tags and values.

  Args:
    expected_tags: All tags in summary.
    expected_simple_values: Simply values for some tags.
    summary_proto: Summary to validate.

  Raises:
    ValueError: if expectations are not met.
  """
  actual_tags = set()
  for value in summary_proto.value:
    actual_tags.add(value.tag)
    if value.tag in expected_simple_values:
      expected = expected_simple_values[value.tag]
      actual = value.simple_value
      np.testing.assert_almost_equal(
          actual, expected, decimal=2, err_msg=value.tag)
  expected_tags = set(expected_tags)
  if expected_tags != actual_tags:
    raise ValueError('Expected tags %s, got %s.' % (expected_tags, actual_tags)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:util_test.py

示例4: to_summary_proto

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def to_summary_proto(summary_str):
  """Create summary based on latest stats.

  Args:
    summary_str: Serialized summary.
  Returns:
    summary_pb2.Summary.
  Raises:
    ValueError: if tensor is not a valid summary tensor.
  """
  summary = summary_pb2.Summary()
  summary.ParseFromString(summary_str)
  return summary


# TODO(ptucker): Move to a non-test package? 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:18,代码来源:util_test.py

示例5: add_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def add_summary(self, summary, global_step=None):
    """Adds a `Summary` protocol buffer to the event file.

    This method wraps the provided summary in an `Event` protocol buffer
    and adds it to the event file.

    You can pass the result of evaluating any summary op, using
    [`Session.run()`](client.md#Session.run) or
    [`Tensor.eval()`](framework.md#Tensor.eval), to this
    function. Alternatively, you can pass a `tf.Summary` protocol
    buffer that you populate with your own data. The latter is
    commonly done to report evaluation results in event files.

    Args:
      summary: A `Summary` protocol buffer, optionally serialized as a string.
      global_step: Number. Optional global step value to record with the
        summary.
    """
    if isinstance(summary, bytes):
      summ = summary_pb2.Summary()
      summ.ParseFromString(summary)
      summary = summ
    event = event_pb2.Event(summary=summary)
    self._add_event(event, global_step) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:26,代码来源:writer.py

示例6: _WriteScalarSummaries

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def _WriteScalarSummaries(self, data, subdirs=('',)):
    # Writes data to a tempfile in subdirs, and returns generator for the data.
    # If subdirs is given, writes data identically to all subdirectories.
    for subdir_ in subdirs:
      subdir = os.path.join(self.logdir, subdir_)
      self._MakeDirectoryIfNotExists(subdir)

      sw = SummaryWriter(subdir)
      for datum in data:
        summary = Summary()
        if 'simple_value' in datum:
          summary.value.add(tag=datum['tag'],
                            simple_value=datum['simple_value'])
          sw.add_summary(summary, global_step=datum['step'])
        elif 'histo' in datum:
          summary.value.add(tag=datum['tag'], histo=HistogramProto())
          sw.add_summary(summary, global_step=datum['step'])
        elif 'session_log' in datum:
          sw.add_session_log(datum['session_log'], global_step=datum['step'])
      sw.close() 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:22,代码来源:event_file_inspector_test.py

示例7: merge_TFSummary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def merge_TFSummary(summary_list, weights):
    merged_values = {}
    weight_sum_map = {}
    for i in range(len(summary_list)):
        summary = summary_list[i]
        if isinstance(summary, bytes):
            parse_TFSummary_from_bytes(summary)
            summ = summary_pb2.Summary()
            summ.ParseFromString(summary)
            summary = summ
        for e in summary.value:
            if e.tag not in merged_values:
                merged_values[e.tag] = 0.0
                weight_sum_map[e.tag] = 0.0
            merged_values[e.tag] += e.simple_value * weights[i]
            weight_sum_map[e.tag] += weights[i]
    for k in merged_values:
        merged_values[k] /= max(0.0000001, weight_sum_map[k])
    return tf.Summary(value=[
        tf.Summary.Value(tag=k, simple_value=merged_values[k]) for k in merged_values
    ]) 
开发者ID:ULTR-Community,项目名称:ULTRA,代码行数:23,代码来源:data_utils.py

示例8: _assert_simple_summaries

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def _assert_simple_summaries(test_case,
                             expected_summaries,
                             summary_str,
                             tol=1e-6):
  """Assert summary the specified simple values.

  Args:
    test_case: test case.
    expected_summaries: Dict of expected tags and simple values.
    summary_str: Serialized `summary_pb2.Summary`.
    tol: Tolerance for relative and absolute.
  """
  summary = summary_pb2.Summary()
  summary.ParseFromString(summary_str)
  test_case.assertAllClose(
      expected_summaries, {v.tag: v.simple_value for v in summary.value},
      rtol=tol,
      atol=tol) 
开发者ID:tensorflow,项目名称:estimator,代码行数:20,代码来源:head_test.py

示例9: _write_checkpoint_path_to_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def _write_checkpoint_path_to_summary(output_dir, checkpoint_path,
                                      current_global_step):
  """Writes `checkpoint_path` into summary file in the given output directory.

  Args:
    output_dir: `str`, directory to write the summary file in.
    checkpoint_path: `str`, checkpoint file path to be written to summary file.
    current_global_step: `int`, the current global step.
  """

  checkpoint_path_tag = 'checkpoint_path'

  tf.compat.v1.logging.info('Saving \'%s\' summary for global step %d: %s',
                            checkpoint_path_tag, current_global_step,
                            checkpoint_path)
  summary_proto = summary_pb2.Summary()
  summary_proto.value.add(
      tag=checkpoint_path_tag,
      tensor=tf.make_tensor_proto(checkpoint_path, dtype=tf.dtypes.string))
  summary_writer = tf.compat.v1.summary.FileWriterCache.get(output_dir)
  summary_writer.add_summary(summary_proto, current_global_step)
  summary_writer.flush() 
开发者ID:tensorflow,项目名称:estimator,代码行数:24,代码来源:estimator.py

示例10: _AddRateToSummary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def _AddRateToSummary(tag, rate, step, sw):
  """Adds the given rate to the summary with the given tag.

  Args:
    tag:   Name for this value.
    rate:  Value to add to the summary. Perhaps an error rate.
    step:  Global step of the graph for the x-coordinate of the summary.
    sw:    Summary writer to which to write the rate value.
  """
  sw.add_summary(
      summary_pb2.Summary(value=[summary_pb2.Summary.Value(
          tag=tag, simple_value=rate)]), step) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:vgsl_model.py

示例11: make_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def make_summary(name, val):
    return summary_pb2.Summary(value=[summary_pb2.Summary.Value(tag=name, simple_value=val)]) 
开发者ID:mkocaoglu,项目名称:CausalGAN,代码行数:4,代码来源:utils.py

示例12: _write_dict_to_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def _write_dict_to_summary(output_dir,
                           dictionary,
                           current_global_step):
  """Writes a `dict` into summary file in given output directory.

  Args:
    output_dir: `str`, directory to write the summary file in.
    dictionary: the `dict` to be written to summary file.
    current_global_step: `int`, the current global step.
  """
  logging.info('Saving dict for global step %d: %s', current_global_step,
               _dict_to_str(dictionary))
  summary_writer = writer_cache.FileWriterCache.get(output_dir)
  summary_proto = summary_pb2.Summary()
  for key in dictionary:
    if dictionary[key] is None:
      continue
    if key  == "global_step":
      continue
    value = summary_proto.value.add()
    value.tag = key
    if (isinstance(dictionary[key], np.float32) or 
        isinstance(dictionary[key], float)):
      value.simple_value = float(dictionary[key])
    elif (isinstance(dictionary[key], np.int64) or
          isinstance(dictionary[key], np.int32) or
          isinstance(dictionary[key], int)):
      value.simple_value = int(dictionary[key])
    else:
      logging.warn('Skipping summary for %s, must be a float, np.float32, np.int64, np.int32 or int.',
                   key)
  summary_writer.add_summary(summary_proto, current_global_step)
  summary_writer.flush() 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:35,代码来源:estimator.py

示例13: add_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def add_summary(self, summary, global_step=None):
    """Adds a `Summary` protocol buffer to the event file.

    This method wraps the provided summary in an `Event` protocol buffer
    and adds it to the event file.

    You can pass the result of evaluating any summary op, using
    @{tf.Session.run} or
    @{tf.Tensor.eval}, to this
    function. Alternatively, you can pass a `tf.Summary` protocol
    buffer that you populate with your own data. The latter is
    commonly done to report evaluation results in event files.

    Args:
      summary: A `Summary` protocol buffer, optionally serialized as a string.
      global_step: Number. Optional global step value to record with the
        summary.
    """
    if isinstance(summary, bytes):
      summ = summary_pb2.Summary()
      summ.ParseFromString(summary)
      summary = summ
    event = event_pb2.Event(wall_time=time.time(), summary=summary)
    if global_step is not None:
      event.step = int(global_step)
    self.add_event(event) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:28,代码来源:summary_iterator.py

示例14: add_summary

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def add_summary(self, summ, current_global_step):
    """Add summary."""
    if isinstance(summ, bytes):
      summary_proto = summary_pb2.Summary()
      summary_proto.ParseFromString(summ)
      summ = summary_proto
    if current_global_step in self._summaries:
      step_summaries = self._summaries[current_global_step]
    else:
      step_summaries = []
      self._summaries[current_global_step] = step_summaries
    step_summaries.append(summ)

  # NOTE: Ignore global_step since its value is non-deterministic. 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:16,代码来源:fake_summary_writer.py

示例15: simple_values_from_events

# 需要导入模块: from tensorflow.core.framework import summary_pb2 [as 别名]
# 或者: from tensorflow.core.framework.summary_pb2 import Summary [as 别名]
def simple_values_from_events(events, tags):
  """Parse summaries from events with simple_value.

  Args:
    events: List of tensorflow.Event protos.
    tags: List of string event tags corresponding to simple_value summaries.
  Returns:
    dict of tag:value.
  Raises:
   ValueError: if a summary with a specified tag does not contain simple_value.
  """
  step_by_tag = {}
  value_by_tag = {}
  for e in events:
    if e.HasField('summary'):
      for v in e.summary.value:
        tag = v.tag
        if tag in tags:
          if not v.HasField('simple_value'):
            raise ValueError('Summary for %s is not a simple_value.' % tag)
          # The events are mostly sorted in step order, but we explicitly check
          # just in case.
          if tag not in step_by_tag or e.step > step_by_tag[tag]:
            step_by_tag[tag] = e.step
            value_by_tag[tag] = v.simple_value
  return value_by_tag 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:28,代码来源:util_test.py


注:本文中的tensorflow.core.framework.summary_pb2.Summary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。