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

Function visualize_conv_weights

examples/basics/mnist-visualizations.py:16–35  ·  view source on GitHub ↗

Visualize use weights in convolution filters. Args: filters: tensor containing the weights [H,W,Cin,Cout] name: label for tensorboard Returns: image of all weight

(filters, name)

Source from the content-addressed store, hash-verified

14
15
16def visualize_conv_weights(filters, name):
17 """Visualize use weights in convolution filters.
18
19 Args:
20 filters: tensor containing the weights [H,W,Cin,Cout]
21 name: label for tensorboard
22
23 Returns:
24 image of all weight
25 """
26 with tf.name_scope('visualize_w_' + name):
27 filters = tf.transpose(filters, (3, 2, 0, 1)) # [h, w, cin, cout] -> [cout, cin, h, w]
28 filters = tf.unstack(filters) # --> cout * [cin, h, w]
29 filters = tf.concat(filters, 1) # --> [cin, cout * h, w]
30 filters = tf.unstack(filters) # --> cin * [cout * h, w]
31 filters = tf.concat(filters, 1) # --> [cout * h, cin * w]
32 filters = tf.expand_dims(filters, 0)
33 filters = tf.expand_dims(filters, -1)
34
35 tf.summary.image('visualize_w_' + name, filters)
36
37
38def visualize_conv_activations(activation, name):

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…