Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _ImageSummary(tag, height, width, colorspace, encoded_image):
from tensorboard.compat.proto.summary_pb2 import Summary
image = Summary.Image(
height=height,
width=width,
colorspace=colorspace,
encoded_image_string=encoded_image)
return Summary(value=[Summary.Value(tag=tag, image=image)])
def _ScalarSummary(tag, val):
from tensorboard.compat.proto.summary_pb2 import Summary
return Summary(value=[Summary.Value(tag=tag, simple_value=val)])
summaries = []
tensors = [
(vertices, MeshPluginData.VERTEX),
(faces, MeshPluginData.FACE),
(colors, MeshPluginData.COLOR)
]
tensors = [tensor for tensor in tensors if tensor[0] is not None]
components = metadata.get_components_bitmask([
content_type for (tensor, content_type) in tensors])
for tensor, content_type in tensors:
summaries.append(
_get_tensor_summary(tag, display_name, description, tensor,
content_type, components, json_config))
return Summary(value=summaries)
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]`.
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)
scalar = make_np(scalar)
assert(scalar.squeeze().ndim == 0), 'scalar should be 0D'
scalar = float(scalar)
return Summary(value=[Summary.Value(tag=name, simple_value=scalar)])
tensor_proto = tensor_util.make_tensor_proto(
tensor.data, dtype=tensor.data_type
)
summary_metadata = metadata.create_summary_metadata(
tag,
None, # display_name
tensor.content_type,
components,
shape,
description,
json_config=json_config,
)
instance_tag = metadata.get_instance_name(tag, tensor.content_type)
summaries.append((instance_tag, summary_metadata, tensor_proto))
summary = summary_pb2.Summary()
for instance_tag, summary_metadata, tensor_proto in summaries:
summary.value.add(
tag=instance_tag, metadata=summary_metadata, tensor=tensor_proto
)
return summary
def _summary_pb(tag, hparams_plugin_data):
"""Create a summary holding the given `HParamsPluginData` message.
Args:
tag: The `str` tag to use.
hparams_plugin_data: The `HParamsPluginData` message to use.
Returns:
A TensorBoard `summary_pb2.Summary` message.
"""
summary = summary_pb2.Summary()
summary_metadata = metadata.create_summary_metadata(hparams_plugin_data)
summary.value.add(tag=tag, metadata=summary_metadata)
return summary
Markdown is supported. Defaults to empty.
Raises:
TypeError: If the type of the data is unsupported.
Returns:
A `tf.Summary` protobuf object.
"""
try:
tensor = tensor_util.make_tensor_proto(data, dtype=np.object)
except TypeError as e:
raise TypeError("tensor must be of type string", e)
summary_metadata = metadata.create_summary_metadata(
display_name=None, description=description
)
summary = summary_pb2.Summary()
summary.value.add(tag=tag, metadata=summary_metadata, tensor=tensor)
return summary
def _ImageSummary(tag, height, width, colorspace, encoded_image):
from tensorboard.compat.proto.summary_pb2 import Summary
image = Summary.Image(
height=height,
width=width,
colorspace=colorspace,
encoded_image_string=encoded_image)
return Summary(value=[Summary.Value(tag=tag, image=image)])