-
-
Save kakauandme/bc64b1886804d4bac24e to your computer and use it in GitHub Desktop.
Tensorflow visualize convolutions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| channels = 32 | |
| img_size = 128 | |
| W_conv1 = weight_variable([5, 5, 1, channels]) | |
| h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1)) | |
| # Produces a tensor of size [-1, img_size, img_size, channels] | |
| ## Prepare for visualization | |
| # Take only convolutions of first image, discard convolutions for other images. | |
| V = tf.slice(h_conv1, (0, 0, 0, 0), (1, -1, -1, -1), name='slice_first_input') | |
| V = tf.reshape(V, (img_size, img_size, channels)) | |
| # Reorder so the channels are in the first dimension, x and y follow. | |
| V = tf.transpose(V, (2, 0, 1)) | |
| # Bring into shape expected by image_summary | |
| V = tf.reshape(V, (-1, img_size, img_size, 1)) | |
| tf.image_summary("first_conv", V) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment