本文整理汇总了Python中tensorflow.python.ops.summary_op_util.summary_scope函数的典型用法代码示例。如果您正苦于以下问题:Python summary_scope函数的具体用法?Python summary_scope怎么用?Python summary_scope使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了summary_scope函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: scalar
def scalar(name, tensor, collections=None, family=None):
"""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.
tensor: 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]`.
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. Which contains a `Summary` protobuf.
Raises:
ValueError: If tensor has the wrong shape or type.
"""
if _summary_op_util.skip_summary():
return _constant_op.constant('')
with _summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
val = _gen_logging_ops.scalar_summary(tags=tag, values=tensor, name=scope)
_summary_op_util.collect(val, collections, [_ops.GraphKeys.SUMMARIES])
return val
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:27,代码来源:summary.py
示例2: audio
def audio(self, name, tensor, sample_rate, max_outputs, family=None):
"""Write an audio summary.
Args:
name: A name for the generated node. Will also serve as a series name in
TensorBoard.
tensor: A 3-D `float32` `Tensor` of shape `[batch_size, frames, channels]`
or a 2-D `float32` `Tensor` of shape `[batch_size, frames]`, or
compatible value type.
sample_rate: A Scalar `float32` `Tensor` indicating the sample rate of the
signal in hertz.
max_outputs: Max number of batch elements to generate audio for.
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
"""
with context.device(self._CPU_DEVICE):
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
gen_summary_ops.write_audio_summary(
self._resource, self._update_global_step_tensor(),
tag,
_maybe_cpu(tensor),
sample_rate=_maybe_cpu(sample_rate),
max_outputs=max_outputs,
name=scope)
开发者ID:SylChan,项目名称:tensorflow,代码行数:25,代码来源:summary_writer.py
示例3: _tensor_summary_v2
def _tensor_summary_v2( # pylint: disable=invalid-name
name,
tensor,
summary_description=None,
collections=None,
summary_metadata=None,
family=None):
# pylint: disable=line-too-long
"""Outputs a `Summary` protocol buffer with a serialized tensor.proto.
NOTE(chizeng): This method is temporary. It should never make it into
TensorFlow 1.3, and nothing should depend on it. This method should be deleted
before August 2017 (ideally, earlier). This method exists to unblock the
TensorBoard plugin refactoring effort. We will later modify the tensor_summary
method to directly make use of the TensorSummaryV2 op. There must be a 3-week
difference between adding a new op (C++) and changing a python interface to
use it.
The generated
[`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
has one summary value containing the input tensor.
Args:
name: A name for the generated node. Will also serve as the series name in
TensorBoard.
tensor: A tensor of any type and shape to serialize.
summary_description: This is currently un-used but must be kept for
backwards compatibility.
collections: Optional list of graph collections keys. The new summary op is
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
summary_metadata: Optional SummaryMetadata proto (which describes which
plugins may use the summary value).
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
"""
# pylint: enable=line-too-long
# The summary description is unused now.
del summary_description
serialized_summary_metadata = ""
if summary_metadata:
serialized_summary_metadata = summary_metadata.SerializeToString()
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
val = gen_logging_ops._tensor_summary_v2(
tensor=tensor,
tag=tag,
description="",
name=scope,
serialized_summary_metadata=serialized_summary_metadata)
summary_op_util.collect(val, collections, [ops.GraphKeys.SUMMARIES])
return val
开发者ID:adityaatluri,项目名称:tensorflow,代码行数:58,代码来源:summary_ops.py
示例4: record
def record():
if bad_color is None:
bad_color_ = constant_op.constant([255, 0, 0, 255], dtype=dtypes.uint8)
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
gen_summary_ops.write_image_summary(
context.context().summary_writer_resource,
training_util.get_global_step(), tag, tensor, bad_color_, max_images,
name=scope)
开发者ID:jiayouwyhit,项目名称:tensorflow,代码行数:9,代码来源:summary_ops.py
示例5: image
def image(self, name, tensor, bad_color=None, max_images=3, family=None):
"""Write an image summary."""
with context.device(self._CPU_DEVICE):
if bad_color is None:
bad_color_ = constant_op.constant([255, 0, 0, 255], dtype=dtypes.uint8)
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
gen_summary_ops.write_image_summary(
self._resource, self._update_global_step_tensor(),
tag, _maybe_cpu(tensor), bad_color_, max_images,
name=scope)
开发者ID:SylChan,项目名称:tensorflow,代码行数:11,代码来源:summary_writer.py
示例6: image
def image(name, tensor, max_outputs=3, collections=None, family=None):
"""Outputs a `Summary` protocol buffer with images.
The summary has up to `max_outputs` summary values containing images. The
images are built from `tensor` which must be 4-D with shape `[batch_size,
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 images have the same number of channels as the input tensor. For float
input, the values are normalized one image at a time to fit in the range
`[0, 255]`. `uint8` values are unchanged. The op uses two different
normalization algorithms:
* If the input values are all positive, they are rescaled so the largest one
is 255.
* If any input value is negative, the values are shifted so input value 0.0
is at 127. They are then rescaled so that either the smallest value is 0,
or the largest one is 255.
The `tag` 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:
name: A name for the generated node. Will also serve as a series name in
TensorBoard.
tensor: A 4-D `uint8` or `float32` `Tensor` of shape `[batch_size, height,
width, channels]` where `channels` is 1, 3, or 4.
max_outputs: Max number of batch elements to generate images for.
collections: Optional list of ops.GraphKeys. The collections to add the
summary to. Defaults to [_ops.GraphKeys.SUMMARIES]
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
"""
if _summary_op_util.skip_summary():
return _constant_op.constant('')
with _summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
val = _gen_logging_ops.image_summary(
tag=tag, tensor=tensor, max_images=max_outputs, name=scope)
_summary_op_util.collect(val, collections, [_ops.GraphKeys.SUMMARIES])
return val
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:53,代码来源:summary.py
示例7: tensor_summary
def tensor_summary(name,
tensor,
summary_description=None,
collections=None,
summary_metadata=None,
family=None,
display_name=None):
"""Outputs a `Summary` protocol buffer with a serialized tensor.proto.
Args:
name: A name for the generated node. If display_name is not set, it will
also serve as the tag name in TensorBoard. (In that case, the tag
name will inherit tf name scopes.)
tensor: A tensor of any type and shape to serialize.
summary_description: A long description of the summary sequence. Markdown
is supported.
collections: Optional list of graph collections keys. The new summary op is
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
summary_metadata: Optional SummaryMetadata proto (which describes which
plugins may use the summary value).
family: Optional; if provided, used as the prefix of the summary tag,
which controls the name used for display on TensorBoard when
display_name is not set.
display_name: A string used to name this data in TensorBoard. If this is
not set, then the node name will be used instead.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
"""
if summary_metadata is None:
summary_metadata = _SummaryMetadata()
if summary_description is not None:
summary_metadata.summary_description = summary_description
if display_name is not None:
summary_metadata.display_name = display_name
serialized_summary_metadata = summary_metadata.SerializeToString()
if _summary_op_util.skip_summary():
return _constant_op.constant('')
with _summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
val = _gen_logging_ops.tensor_summary_v2(
tensor=tensor,
tag=tag,
name=scope,
serialized_summary_metadata=serialized_summary_metadata)
_summary_op_util.collect(val, collections, [_ops.GraphKeys.SUMMARIES])
return val
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:53,代码来源:summary.py
示例8: audio
def audio(name, tensor, sample_rate, max_outputs=3, collections=None,
family=None):
# pylint: disable=line-too-long
"""Outputs a `Summary` protocol buffer with audio.
The summary has up to `max_outputs` summary values containing audio. The
audio is built from `tensor` which must be 3-D with shape `[batch_size,
frames, channels]` or 2-D with shape `[batch_size, frames]`. The values are
assumed to be in the range of `[-1.0, 1.0]` with a sample rate of
`sample_rate`.
The `tag` 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*/audio'.
* If `max_outputs` is greater than 1, the summary value tags are
generated sequentially as '*name*/audio/0', '*name*/audio/1', etc
Args:
name: A name for the generated node. Will also serve as a series name in
TensorBoard.
tensor: A 3-D `float32` `Tensor` of shape `[batch_size, frames, channels]`
or a 2-D `float32` `Tensor` of shape `[batch_size, frames]`.
sample_rate: A Scalar `float32` `Tensor` indicating the sample rate of the
signal in hertz.
max_outputs: Max number of batch elements to generate audio for.
collections: Optional list of ops.GraphKeys. The collections to add the
summary to. Defaults to [_ops.GraphKeys.SUMMARIES]
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
"""
if _summary_op_util.skip_summary():
return _constant_op.constant('')
with _summary_op_util.summary_scope(
name, family=family, values=[tensor]) as (tag, scope):
sample_rate = _ops.convert_to_tensor(
sample_rate, dtype=_dtypes.float32, name='sample_rate')
val = _gen_logging_ops.audio_summary_v2(
tag=tag, tensor=tensor, max_outputs=max_outputs,
sample_rate=sample_rate, name=scope)
_summary_op_util.collect(val, collections, [_ops.GraphKeys.SUMMARIES])
return val
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:46,代码来源:summary.py
示例9: histogram
def histogram(self, name, tensor, family=None):
"""Write a histogram summary.
Args:
name: A name for the generated node. Will also serve as a series name in
TensorBoard.
tensor: A real numeric `Tensor` or compatible value type. Any shape.
Values to use to build the histogram.
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
"""
with context.device(self._CPU_DEVICE):
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
gen_summary_ops.write_histogram_summary(
self._resource, self._update_global_step_tensor(),
tag, _maybe_cpu(tensor), name=scope)
开发者ID:SylChan,项目名称:tensorflow,代码行数:17,代码来源:summary_writer.py
示例10: tensor_summary
def tensor_summary(
name,
tensor,
summary_description=None,
collections=None,
summary_metadata=None,
family=None):
"""Outputs a `Summary` protocol buffer with a serialized tensor.proto.
Args:
name: A name for the generated node. Will also serve as the series name in
TensorBoard.
tensor: A tensor of any type and shape to serialize.
summary_description: This is currently un-used but must be kept for
backwards compatibility.
collections: Optional list of graph collections keys. The new summary op is
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
summary_metadata: Optional SummaryMetadata proto (which describes which
plugins may use the summary value).
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
"""
# The summary description is unused now.
del summary_description
serialized_summary_metadata = ""
if summary_metadata:
serialized_summary_metadata = summary_metadata.SerializeToString()
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
val = gen_logging_ops._tensor_summary_v2(
tensor=tensor,
tag=tag,
name=scope,
serialized_summary_metadata=serialized_summary_metadata)
summary_op_util.collect(val, collections, [ops.GraphKeys.SUMMARIES])
return val
开发者ID:awisbith,项目名称:tensorflow,代码行数:42,代码来源:summary_ops.py
示例11: scalar
def scalar(self, name, tensor, family=None):
"""Write a scalar summary.
Args:
name: A name for the generated node. Will also serve as the series name in
TensorBoard.
tensor: A real numeric `Tensor` or compatible value type containing a
single value.
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A summary writer function for scalars.
"""
with context.device(self._CPU_DEVICE):
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
gen_summary_ops.write_scalar_summary(
self._resource, self._update_global_step_tensor(),
tag, _maybe_cpu(tensor), name=scope)
开发者ID:SylChan,项目名称:tensorflow,代码行数:20,代码来源:summary_writer.py
示例12: gif_summary
def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None,
family=None):
"""Outputs a `Summary` protocol buffer with gif animations.
Args:
name: Name of the summary.
tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width,
channels]` where `channels` is 1 or 3.
max_outputs: Max number of batch elements to generate gifs for.
fps: frames per second of the animation
collections: Optional list of tf.GraphKeys. The collections to add the
summary to. Defaults to [tf.GraphKeys.SUMMARIES]
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
Raises:
ValueError: if the given tensor has the wrong shape.
"""
tensor = tf.convert_to_tensor(tensor)
if len(tensor.get_shape()) != 5:
raise ValueError("Assuming videos given as tensors in the format "
"[batch, time, height, width, channels] but got one "
"of shape: %s" % str(tensor.get_shape()))
tensor = tf.cast(tensor, tf.uint8)
if summary_op_util.skip_summary():
return tf.constant("")
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
val = tf.py_func(
py_gif_summary,
[tag, tensor, max_outputs, fps],
tf.string,
stateful=False,
name=scope)
summary_op_util.collect(val, collections, [tf.GraphKeys.SUMMARIES])
return val
开发者ID:qixiuai,项目名称:tensor2tensor,代码行数:40,代码来源:common_video.py
示例13: generic
def generic(self, name, tensor, metadata, family=None):
"""Write a generic-type summary.
Args:
name: A name for the generated node. Will also serve as the series name in
TensorBoard.
tensor: A `Tensor` or compatible value type containing the value of the
summary.
metadata: Metadata about the summary.
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
"""
with context.device(self._CPU_DEVICE):
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
gen_summary_ops.write_summary(
self._resource,
self._update_global_step_tensor(),
_maybe_cpu(tensor),
tag,
_maybe_cpu(metadata),
name=scope)
开发者ID:SylChan,项目名称:tensorflow,代码行数:22,代码来源:summary_writer.py
示例14: histogram
def histogram(name, values, collections=None, family=None):
# pylint: disable=line-too-long
"""Outputs a `Summary` protocol buffer with a histogram.
Adding a histogram summary makes it possible to visualize your data's
distribution in TensorBoard. You can see a detailed explanation of the
TensorBoard histogram dashboard
[here](https://www.tensorflow.org/get_started/tensorboard_histograms).
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.
collections: Optional list of graph collections keys. The new summary op is
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
family: Optional; if provided, used as the prefix of the summary tag name,
which controls the tab name used for display on Tensorboard.
Returns:
A scalar `Tensor` of type `string`. The serialized `Summary` protocol
buffer.
"""
if _summary_op_util.skip_summary():
return _constant_op.constant('')
with _summary_op_util.summary_scope(
name, family, values=[values],
default_name='HistogramSummary') as (tag, scope):
val = _gen_logging_ops.histogram_summary(
tag=tag, values=values, name=scope)
_summary_op_util.collect(val, collections, [_ops.GraphKeys.SUMMARIES])
return val
开发者ID:abhinav-upadhyay,项目名称:tensorflow,代码行数:38,代码来源:summary.py
示例15: record
def record():
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
with ops.control_dependencies([function(tag, scope)]):
return constant_op.constant(True)
开发者ID:ChengYuXiang,项目名称:tensorflow,代码行数:5,代码来源:summary_ops.py
示例16: record
def record():
with summary_op_util.summary_scope(
name, family, values=[tensor]) as (tag, scope):
function(tag, scope)
return True
开发者ID:SylChan,项目名称:tensorflow,代码行数:5,代码来源:summary_writer.py
注:本文中的tensorflow.python.ops.summary_op_util.summary_scope函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论