MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / visualize_tensors

Function visualize_tensors

examples/GAN/Image2Image.py:47–61  ·  view source on GitHub ↗

Generate tensor for TensorBoard (casting, clipping) Args: name: name for visualization operation *imgs: multiple tensors as list scale_func: scale input tensors to fit range [0, 255] Example: visualize_tensors('viz1', [img1]) visualize_tensors('viz2'

(name, imgs, scale_func=lambda x: (x + 1.) * 128., max_outputs=1)

Source from the content-addressed store, hash-verified

45
46
47def visualize_tensors(name, imgs, scale_func=lambda x: (x + 1.) * 128., max_outputs=1):
48 """Generate tensor for TensorBoard (casting, clipping)
49
50 Args:
51 name: name for visualization operation
52 *imgs: multiple tensors as list
53 scale_func: scale input tensors to fit range [0, 255]
54
55 Example:
56 visualize_tensors('viz1', [img1])
57 visualize_tensors('viz2', [img1, img2, img3], max_outputs=max(30, BATCH))
58 """
59 xy = scale_func(tf.concat(imgs, axis=2))
60 xy = tf.cast(tf.clip_by_value(xy, 0, 255), tf.uint8, name='viz')
61 tf.summary.image(name, xy, max_outputs=30)
62
63
64class Model(GANModelDesc):

Callers 1

build_graphMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…