Answers.Body: <p>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 &quot;filter out&quot; different features.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-12T22:42:44.817Z
Answers.LastActivityDate: 2020-10-12T22:42:44.817Z
Answers.UserDisplayName: Tom Dörr
Answers.Body: <blockquote>
  <p>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?</p>
  </blockquote>
  <p>The filters (aka kernels) are the <strong>learnable parameters</strong> 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).</p>
  <p>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.</p>
  <p>To answer your question more directly, the only thing that usually changes is just the value of the filters. The <a href="https://ai.stackexchange.com/q/21999/2444">convolution (or cross-correlation)</a> operation is the same for all filters.</p>
  <p>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).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-12T22:40:17.353Z
Answers.LastActivityDate: 2020-10-15T21:18:16.030Z
Answers.LastEditDate: 2020-10-15T21:18:16.030Z
Answers.UserDisplayName: nbro
Body: <p>Consider the following coding line related to CNNS</p>
  <pre><code>Conv2D(64, (3,3), strides=(2, 2), padding='same')
  </code></pre>
  <p>It is a convolution layer with filter size <span class="math-container">$3 \times 3$</span> and step size of <span class="math-container">$2\times 2$</span>.</p>
  <p>I am confused about the need for <span class="math-container">$64$</span> filters.</p>
  <p>Are they doing the same task? Obviously, it is no. (one is enough in this case)</p>
  <p>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?</p>
  <p>I am finding difficulty in visualizing it.</p>
  
Tags: <convolutional-neural-networks><computer-vision><keras><filters><convolutional-layers>
Title: What is the need for so many filters in a CNN?
UserDisplayName: hanugm
ThreadText: # What is the need for so many filters in a CNN?
  
  (Asked by: username_0 on 2020-10-12)
  
  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.
  
  **Tags:** convolutional-neural-networks, computer-vision, keras, filters, convolutional-layers
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-10-12. Score: 4 | Accepted answer
  
  > 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)](https://ai.stackexchange.com/q/21999/2444) 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).
  
  
  ---
  
  ### Answer by username_1 on 2020-10-12. Score: 1
  
  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.
  
  
  ---
  
  