写一个图像摘要。
用法
tf.summary.image(
name, data, step=None, max_outputs=3, description=None
)
参数
-
name
此摘要的名称。用于 TensorBoard 的摘要标记将是此名称,以任何活动名称范围为前缀。 -
data
一个Tensor
表示像素数据,形状为[k, h, w, c]
,其中k
是图像数量,h
和w
是图像的高度和宽度,c
是通道数,其中应为 1、2、3 或 4(灰度、带 alpha 的灰度、RGB、RGBA)。任何尺寸都可能是静态未知的(即None
)。浮点数据将被裁剪到 [0,1] 范围内。使用tf.image.convert_image_dtype
将其他数据类型剪裁到允许的范围内,以便安全地转换为 uint8。 -
step
此摘要的显式int64
-castable 单调步长 值。如果省略,则默认为tf.summary.experimental.get_step()
,不能为 None。 -
max_outputs
可选的int
或 rank-0 整数Tensor
。每一步最多会发出这么多图像。当提供多于max_outputs
many 图像时,将使用前max_outputs
many 图像,其余的将被静默丢弃。 -
description
此摘要的可选长格式说明,作为常量str
。支持Markdown 。默认为空。
返回
- 成功时为真,如果因为没有可用的默认摘要编写器而未发出摘要,则为假。
抛出
-
ValueError
如果存在默认编写器,但未提供任何步骤且tf.summary.experimental.get_step()
为无。
另见tf.summary.scalar
、tf.summary.SummaryWriter
。
将图像集合写入当前默认摘要编写器。数据显示在 TensorBoard 的 'Images' 仪表板中。与 tf.summary.scalar
点一样,每个图像集合都与 step
和 name
相关联。所有具有相同name
的图像集合构成一个时间序列的图像集合。
此示例写入 2 个随机灰度图像:
w = tf.summary.create_file_writer('test/logs')
with w.as_default():
image1 = tf.random.uniform(shape=[8, 8, 1])
image2 = tf.random.uniform(shape=[8, 8, 1])
tf.summary.image("grayscale_noise", [image1, image2], step=0)
为避免裁剪,应将数据转换为以下之一:
- [0,1] 范围内的浮点值,或
- [0,255] 范围内的 uint8 值
# Convert the original dtype=int32 `Tensor` into `dtype=float64`.
rgb_image_float = tf.constant([
[[1000, 0, 0], [0, 500, 1000]],
]) / 1000
tf.summary.image("picture", [rgb_image_float], step=0)
# Convert original dtype=uint8 `Tensor` into proper range.
rgb_image_uint8 = tf.constant([
[[1, 1, 0], [0, 0, 1]],
], dtype=tf.uint8) * 255
tf.summary.image("picture", [rgb_image_uint8], step=1)
相关用法
- Python tf.summary.scalar用法及代码示例
- Python tf.summary.text用法及代码示例
- Python tf.summary.record_if用法及代码示例
- Python tf.summary.experimental.summary_scope用法及代码示例
- Python tf.summary.histogram用法及代码示例
- Python tf.summary.SummaryWriter.as_default用法及代码示例
- Python tf.summary.graph用法及代码示例
- Python tf.strings.substr用法及代码示例
- Python tf.strings.reduce_join用法及代码示例
- Python tf.sparse.cross用法及代码示例
- Python tf.sparse.mask用法及代码示例
- Python tf.strings.regex_full_match用法及代码示例
- Python tf.sparse.split用法及代码示例
- Python tf.strings.regex_replace用法及代码示例
- Python tf.signal.overlap_and_add用法及代码示例
- Python tf.strings.length用法及代码示例
- Python tf.strided_slice用法及代码示例
- Python tf.sparse.to_dense用法及代码示例
- Python tf.strings.bytes_split用法及代码示例
- Python tf.shape用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.summary.image。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。