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)
| 14 | |
| 15 | |
| 16 | def 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 | |
| 38 | def visualize_conv_activations(activation, name): |
no outgoing calls
no test coverage detected
searching dependent graphs…