Convolutional Neural Networks
May 13, 2019
May 13, 2019

A filter can technically just be thought of as a relatively small matrix (kernel), for which, we decide the number of rows and columns this matrix has, and the values within this matrix are initialized with random numbers.
In this example, on the first convolutional layer, we’re going to specify that we want the layer to contain one filter of size 3 x 3.
This image shows us one step in the convolution process. For each position on the blue input channel, the 3 x 3 filter does a computation that maps the colored part of the blue input channel to the corresponding colored part of the red output channel.
This convolutional layer receives an input channel, and the filter will slide over each 3 x 3 set of pixels of the input itself until it covers over every 3 x 3 block of pixels from the entire image.
Let’s suppose that we have four 3 x 3 filters for our first convolutional layer, and these filters are filled with the values you see below. These values can be represented visually by having -1s correspond to black, 1s correspond to white, and 0s correspond to grey.
On the image above we can see a convolutional layer with 4 filters. If we convolve our original image of a seven with each of these four filters individually, this is what the output would look like for each filter:
We can see that all four of these filters are detecting edges. In the output channels, the brightest pixels can be interpreted as what the filter has detected. In the first one, we can see detects top horizontal edges of the seven, and that’s indicated by the brightest pixels (white).
The second detects left vertical edges, again being displayed with the brightest pixels. The third detect bottom horizontal edges, and the fourth detects right vertical edges.
These filters, as we mentioned before, are really basic and just detect edges. These are filters we may see towards the start of a convolutional neural network. More complex filters would be located deeper in the network and would gradually be able to detect more sophisticated patterns.