In this article, we delve into the fascinating concept of filters within Convolutional Neural Networks (CNNs). We will explain how filters are used to extract features from input data and create feature maps.
Why Filters?
In a CNN, each cell in a convolutional layer receives information from a group of pixels or cells in the previous layer. But how does this happen? How is a cell able to gather information from numerous pixels? We have 25 pixels here and our cell can only hold one value representing all these pixels. So we need a way to convert these 25 values into one value.
The Role of Filters
Filters are matrices with the same dimensions as the receptive field (e.g., if the window is 5x5, the filter will also be 5x5). A filter multiplies each pixel value by the corresponding filter value and adds up all these products to generate a single number, representing the information in those pixels.
Determining Filter Values
The values in the filters are not manually chosen. During training, our network learns these values itself.
Demystifying Filters with Examples
To illustrate how filters function and highlight specific features, we'll use a 5x5 input image with pixel values of 0.1 and a 3x3 filter. Observe this filter: it resembles a cross, with diagonal values being 1 and the others 0.
With a stride of 1, using this filter, we get the output as shown in the GIF below.
By multiplying the pixel values with their respective filter values and summing up these products, we obtain a number that represents the information within these 25 pixels. Now, to demonstrate how filters work, I have taken a 5x5 input image with 0.1 type pixel values and a 3x3 filter.
Feature Maps
The output after applying a filter is called a feature map. Each feature map highlights a specific feature of the input image. To better understand this, let's examine some examples:
Multiple Filters for Multiple Features
To create various feature maps with different features, we apply multiple types of filters. Each convolutional layer becomes a bundle of feature maps, each highlighting specific features. This is crucial because in the next layer, each cell will process information from all feature maps in the previous layer to identify more complex features.
Stay Tuned!
In the next article, we'll discuss channels in CNNs and explore how they impact the output layer.
FAQs
Let's discuss your project and find the best solution for your business.