本文整理汇总了Python中tensorflow.python.summary.summary.histogram方法的典型用法代码示例。如果您正苦于以下问题:Python summary.histogram方法的具体用法?Python summary.histogram怎么用?Python summary.histogram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.summary.summary
的用法示例。
在下文中一共展示了summary.histogram方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_gradients_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_gradients_summaries(grads_and_vars):
"""Add summaries to gradients.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The list of created summaries.
"""
summaries = []
for grad, var in grads_and_vars:
if grad is not None:
if isinstance(grad, ops.IndexedSlices):
grad_values = grad.values
else:
grad_values = grad
summaries.append(
summary.histogram(var.op.name + '/gradient', grad_values))
summaries.append(
summary.scalar(var.op.name + '/gradient_norm',
clip_ops.global_norm([grad_values])))
else:
logging.info('Var %s has no gradient', var.op.name)
return summaries
示例2: _add_scalar_summary
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def _add_scalar_summary(tensor, tag=None):
"""Add a scalar summary operation for the tensor.
Args:
tensor: The tensor to summarize.
tag: The tag to use, if None then use tensor's op's name.
Returns:
The created histogram summary.
Raises:
ValueError: If the tag is already in use or the rank is not 0.
"""
tensor.get_shape().assert_has_rank(0)
tag = tag or '%s_summary' % tensor.op.name
return summary.scalar(tag, tensor)
示例3: add_gradients_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_gradients_summaries(grads_and_vars):
"""Add summaries to gradients.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The list of created summaries.
"""
summaries = []
for grad, var in grads_and_vars:
if grad is not None:
if isinstance(grad, ops.IndexedSlices):
grad_values = grad.values
else:
grad_values = grad
summaries.append(
summary.histogram(var.op.name + '_gradient', grad_values))
summaries.append(
summary.scalar(var.op.name + '_gradient_norm',
clip_ops.global_norm([grad_values])))
else:
logging.info('Var %s has no gradient', var.op.name)
return summaries
示例4: add_gradients_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_gradients_summaries(grads_and_vars):
"""Add summaries to gradients.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The list of created summaries.
"""
summaries = []
for grad, var in grads_and_vars:
if grad is not None:
if isinstance(grad, ops.IndexedSlices):
grad_values = grad.values
else:
grad_values = grad
summaries.append(
summary.histogram(var.op.name + '/gradient', grad_values))
summaries.append(
summary.histogram(var.op.name + '/gradient_norm',
clip_ops.global_norm([grad_values])))
else:
logging.info('Var %s has no gradient', var.op.name)
return summaries
示例5: add_gradients_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_gradients_summaries(grads_and_vars):
"""Add summaries to gradients.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The list of created summaries.
"""
summaries = []
for grad, var in grads_and_vars:
if grad is not None:
if isinstance(grad, ops.IndexedSlices):
grad_values = grad.values
else:
grad_values = grad
summaries.append(
summary.histogram(var.op.name + '_gradient', grad_values))
summaries.append(
summary.histogram(var.op.name + '_gradient_norm',
clip_ops.global_norm([grad_values])))
else:
logging.info('Var %s has no gradient', var.op.name)
return summaries
示例6: add_gradients_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_gradients_summaries(grads_and_vars):
"""Add summaries to gradients.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The list of created summaries.
"""
summaries = []
for grad, var in grads_and_vars:
if grad is not None:
if isinstance(grad, ops.IndexedSlices):
grad_values = grad.values
else:
grad_values = grad
summaries.append(
summary.histogram(var.op.name + '/gradient', grad_values))
summaries.append(
summary.scalar(var.op.name + '/gradient_norm',
clip_ops.global_norm([grad_values])))
else:
logging.info('Var %s has no gradient', var.op.name)
return summaries
示例7: add_gradients_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_gradients_summaries(grads_and_vars):
"""Add summaries to gradients.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The list of created summaries.
"""
summaries = []
for grad, var in grads_and_vars:
if grad is not None:
if isinstance(grad, ops.IndexedSlices):
grad_values = grad.values
else:
grad_values = grad
summaries.append(
summary.histogram(var.op.name + '/gradient', grad_values))
summaries.append(
summary.scalar(var.op.name + '/gradient_norm',
clip_ops.global_norm([grad_values])))
else:
log.warn('Var %s has no gradient', var.op.name)
return summaries
示例8: _add_histogram_summary
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def _add_histogram_summary(tensor, tag=None):
"""Add a summary operation for the histogram of a tensor.
Args:
tensor: The tensor to summarize.
tag: The tag to use, if None then use tensor's op's name.
Returns:
The created histogram summary.
Raises:
ValueError: If the tag is already in use.
"""
tag = tag or '%s_summary' % tensor.op.name
return summary.histogram(tag, tensor)
示例9: summarize_tensor
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def summarize_tensor(tensor, tag=None):
"""Summarize a tensor using a suitable summary type.
This function adds a summary op for `tensor`. The type of summary depends on
the shape of `tensor`. For scalars, a `scalar_summary` is created, for all
other tensors, `histogram_summary` is used.
Args:
tensor: The tensor to summarize
tag: The tag to use, if None then use tensor's op's name.
Returns:
The summary op created or None for string tensors.
"""
# Skips string tensors and boolean tensors (not handled by the summaries).
if (tensor.dtype.is_compatible_with(dtypes.string) or
tensor.dtype.base_dtype == dtypes.bool):
return None
if tensor.get_shape().ndims == 0:
# For scalars, use a scalar summary.
return _add_scalar_summary(tensor, tag)
else:
# We may land in here if the rank is still unknown. The histogram won't
# hurt if this ends up being a scalar.
return _add_histogram_summary(tensor, tag)
示例10: _add_hidden_layer_summary
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def _add_hidden_layer_summary(self, value, tag):
# TODO(zakaria): Move this code to tf.learn and add test.
summary.scalar("%s/fraction_of_zero_values" % tag, nn.zero_fraction(value))
summary.histogram("%s/activation" % tag, value)
示例11: _add_hidden_layer_summary
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def _add_hidden_layer_summary(value, tag):
summary.scalar("%s_fraction_of_zero_values" % tag, nn.zero_fraction(value))
summary.histogram("%s_activation" % tag, value)
示例12: _add_hidden_layer_summary
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def _add_hidden_layer_summary(value, tag):
summary.scalar("%s/fraction_of_zero_values" % tag, nn.zero_fraction(value))
summary.histogram("%s/activation" % tag, value)
示例13: add_histogram_summary
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_histogram_summary(tensor, name=None, prefix=None):
"""Adds a histogram summary for the given tensor.
Args:
tensor: A variable or op tensor.
name: The optional name for the summary.
prefix: An optional prefix for the summary names.
Returns:
A scalar `Tensor` of type `string` whose contents are the serialized
`Summary` protocol buffer.
"""
return summary.histogram(
_get_summary_name(tensor, name, prefix), tensor)
示例14: add_histogram_summaries
# 需要导入模块: from tensorflow.python.summary import summary [as 别名]
# 或者: from tensorflow.python.summary.summary import histogram [as 别名]
def add_histogram_summaries(tensors, prefix=None):
"""Adds a histogram summary for each of the given tensors.
Args:
tensors: A list of variable or op tensors.
prefix: An optional prefix for the summary names.
Returns:
A list of scalar `Tensors` of type `string` whose contents are the
serialized `Summary` protocol buffer.
"""
summary_ops = []
for tensor in tensors:
summary_ops.append(add_histogram_summary(tensor, prefix=prefix))
return summary_ops