Answers.Body: <p>If you have a conv layer that has 3 input channels and 32 output channels (i.e. the number of filters), then you essentially have <span class="math-container">$3 \times 32$</span> convolution operations connecting every input channel to every output channel (unless you are doing depthwise-separable convolution which is a different story). This gives you <span class="math-container">$3 \times 32$</span> sets of convolution kernels.</p>
  <p>More concretely, filter 0 contains 3 sets of convolution kernels which convolves respectively with the 3 input features, the 3 outputs of the convolution operations are then summed into output channel 0. And the same applies to filter 1, filter 2, ..., filter 31.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-06T14:55:15.243Z
Answers.Text: Thank you for your answer! Just to be clear, the summed element values of the convolution operations are not divided by the number of channel inputs prior to be put into the output channel related to said filter right? Thanks again!
Answers.UserDisplayName: Blue Ross
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-06T18:32:51.210Z
Answers.Text: @BlueRoss No they are not. Though during the weight initialization, the weights would be initialized smaller if there are more input channels, to prevent the features from exploding in the forward pass
Answers.UserDisplayName: PeaBrane
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-06T05:35:15.760Z
Answers.LastActivityDate: 2022-09-06T05:35:15.760Z
Answers.UserDisplayName: PeaBrane
Body: <p>I was studying Convolutional Layers and some of their variations and I came across this <a href="https://stackoverflow.com/questions/66165196/feature-map-of-convolutional-neural-network-and-total-number-of-parameters">post</a> which says:</p>
  <p>'<em>For rgb vs greyscale, think about channels as feature maps for input layer and <strong>a filter gets applied on all feature map at once.</strong></em>'</p>
  <p>I also watched some videos that say the same thing, however I can't quite understand how the process actually happens. Let's look at the <a href="https://towardsdatascience.com/what-is-wrong-with-convolutional-neural-networks-75c2ba8fbd6f" rel="nofollow noreferrer">image</a> below:</p>
  <p><a href="https://i.sstatic.net/Aq8bL.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Aq8bL.gif" alt="enter image description here" /></a></p>
  <p>Now, lets pretend that we feed an RGB image to a <a href="https://keras.io/api/layers/convolution_layers/convolution2d/" rel="nofollow noreferrer">ConvLayer2D</a>. Since we have an RGB image we also have 3 input channels, one for each color. Lets also suppose that the ConvLayer has 32 filters. From what I understood the output of this layer will be 32 feature maps which means that each filter will apply convolutions to each of the 3 input channels and combine its convolved feature into one feature map related to that same filter. But how does that mixing/combining actually work? Does it produce 3 convolved feature maps (one for each channel input) and then combine its elements by some adding and dividing each elements of said convolved features before putting them into the final feature map? Or does it achieve the 32 feature maps in some other way?</p>
  <p>For example: <em>((Red-i00 + Green-i00 + Blue-i00) / 3 = FinalFeatureMapOfThatFilter-i00 )</em>
  Where i00 represents the top, leftmost position of the related convolved feature.</p>
  <p>Thanks!</p>
  
Tags: <deep-learning><convolutional-neural-networks><convolutional-layers>
Title: How is a filter actually applied to all input channels in a ConvLayer2D
UserDisplayName: Blue Ross
ThreadText: # How is a filter actually applied to all input channels in a ConvLayer2D
  
  (Asked by: username_0 on 2022-09-05)
  
  I was studying Convolutional Layers and some of their variations and I came across this [post](https://stackoverflow.com/questions/66165196/feature-map-of-convolutional-neural-network-and-total-number-of-parameters) which says:
  
  '*For rgb vs greyscale, think about channels as feature maps for input layer and **a filter gets applied on all feature map at once.***'
  
  I also watched some videos that say the same thing, however I can't quite understand how the process actually happens. Let's look at the [image](https://towardsdatascience.com/what-is-wrong-with-convolutional-neural-networks-75c2ba8fbd6f) below:
  
  [![enter image description here](https://i.sstatic.net/Aq8bL.gif)](https://i.sstatic.net/Aq8bL.gif)
  
  Now, lets pretend that we feed an RGB image to a [ConvLayer2D](https://keras.io/api/layers/convolution_layers/convolution2d/). Since we have an RGB image we also have 3 input channels, one for each color. Lets also suppose that the ConvLayer has 32 filters. From what I understood the output of this layer will be 32 feature maps which means that each filter will apply convolutions to each of the 3 input channels and combine its convolved feature into one feature map related to that same filter. But how does that mixing/combining actually work? Does it produce 3 convolved feature maps (one for each channel input) and then combine its elements by some adding and dividing each elements of said convolved features before putting them into the final feature map? Or does it achieve the 32 feature maps in some other way?
  
  For example: *((Red-i00 + Green-i00 + Blue-i00) / 3 = FinalFeatureMapOfThatFilter-i00 )*
  Where i00 represents the top, leftmost position of the related convolved feature.
  
  Thanks!
  
  **Tags:** deep-learning, convolutional-neural-networks, convolutional-layers
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-09-06. Score: 2 | Accepted answer
  
  If you have a conv layer that has 3 input channels and 32 output channels (i.e. the number of filters), then you essentially have $3 \times 32$ convolution operations connecting every input channel to every output channel (unless you are doing depthwise-separable convolution which is a different story). This gives you $3 \times 32$ sets of convolution kernels.
  
  More concretely, filter 0 contains 3 sets of convolution kernels which convolves respectively with the 3 input features, the 3 outputs of the convolution operations are then summed into output channel 0. And the same applies to filter 1, filter 2, ..., filter 31.
  
  > **Comments:**
  > **username_0**: Thank you for your answer! Just to be clear, the summed element values of the convolution operations are not divided by the number of channel inputs prior to be put into the output channel related to said filter right? Thanks again!  
  > **username_1**: @BlueRoss No they are not. Though during the weight initialization, the weights would be initialized smaller if there are more input channels, to prevent the features from exploding in the forward pass  
  
  ---
  
  