2
$\begingroup$

Consider the following coding line related to CNNS

Conv2D(64, (3,3), strides=(2, 2), padding='same')

It is a convolution layer with filter size $3 \times 3$ and step size of $2\times 2$.

I am confused about the need for $64$ filters.

Are they doing the same task? Obviously, it is no. (one is enough in this case)

Then how do each filter differ by? Is it in hovering over the input matrix? Or is it in the values contained by filter itself? Or differs in both hovering and content?

I am finding difficulty in visualizing it.

$\endgroup$

2 Answers 2

3
$\begingroup$

Then how do each filter differ by? Is it in hovering over the input matrix? Or is it in the values contained by filter itself? Or differs in both hovering and content?

The filters (aka kernels) are the learnable parameters of the CNN, in the same way that the weights of the connections between the neurons (or nodes) are the learnable parameters of a multi-layer perceptron (or feed-forward neural network).

So, the value of these filters is not fixed or pre-determined, but will depend on how you train the CNN, i.e. the learning algorithm, the objective function and the data. If you use gradient descent as the learning algorithm, you will be minimizing a loss (aka cost or error) function (e.g. the cross-entropy, in the case of classification problems). To do that, you need to find the gradient of the loss function with respect to the filters. You then apply a step of gradient descent (i.e. you add a scaled version of the gradient of the loss function with respect to the parameters to the parameters), so that this loss decreases.

To answer your question more directly, the only thing that usually changes is just the value of the filters. The convolution (or cross-correlation) operation is the same for all filters.

Why do you use more than one filter? The usual explanation is that each filter, when convolved with the input, will extract different features from it, and the specific features that they will extract will depend on the specific values of the filters, which, in turn, depend on the data, so we can say that CNNs are data-driven feature extractors. If you are familiar with image processing techniques, then you know that different filters, when convolved with the same image, can have different effects (e.g. blurring or de-noising).

$\endgroup$
1
$\begingroup$

All filters move across the same area, but the filter values (also called filter kernels) are different for each filter. This makes it possible to "filter out" different features.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .