Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can visualize tensorflow convolution filters?

Example

In many documents, there are images about each filter like "Example". I want to visual my convolution filters like "Example" image, but I don't know how can visualize it.

How can I visualize my convolution filters?

like image 358
Hyeonjin Jang Avatar asked Sep 07 '16 05:09

Hyeonjin Jang


People also ask

How does convolution filter work?

A convolution is the simple application of a filter to an input that results in an activation. Repeated application of the same filter to an input results in a map of activations called a feature map, indicating the locations and strength of a detected feature in an input, such as an image.

How do we get values for the filters in CNN?

In a CNN, the values for the various filters in each convolutional layer is obtained by training on a particular training set. At the end of the training, you would have a unique set of filter values that are used for detecting specific features in the dataset.

How do convolutional neural networks learn filters?

Learning filter kernels At each position of our sliding window, a mathematical operation is performed, the so called convolution. During convolution, each pixel value in our window is multiplied with the value at the respective position in the filter matrix and the sum of all multiplications is calculated.


3 Answers

Think about each convolutional filter as x by x matrix, where x is the size of the filter. So your task is to put those matrices on a plot grid. I have made an example how to plot convolutional filters and output of convolutional layers using MNIST dataset, see conviz repository on github. Hope it helps you.

like image 140
Sergii Gryshkevych Avatar answered Oct 17 '22 11:10

Sergii Gryshkevych


No those aren't the filters. You can read this paper which describes the procedures from converting the layer L's filters into these images. In short words what it does is taking some filter, and uses a technique similar but not the same as back-propagation to convert the filter into an image.

like image 36
khaled Fouda Avatar answered Oct 17 '22 12:10

khaled Fouda


The result of the 2d convolution is a tensor [batch, in_height, in_width, in_channels]. The image can be represented as a matrix [in_height, in_width, in_channels]. So all you need to do is to grab a few images from your batch, and add them to your summary with tf.summary.image().

For a tutorial how to do this, take a look at this answer.

like image 1
Salvador Dali Avatar answered Oct 17 '22 11:10

Salvador Dali