Answers.Body: <p>The application of 1 kernel (aka filter) to an input (with a 2d convolution) is a matrix (a 2d array), which is often known as a <strong>feature map</strong> (aka activation map). The application of <span class="math-container">$k$</span> kernels to the same input is a 3d array (sometimes called <em>tensor</em>, though this may not be exactly correct, or 3d <em>volume</em>) with depth <span class="math-container">$k$</span>, i.e. you have <span class="math-container">$k$</span> concatenated feature maps. This 3d array is the input to the next convolutional layer, which needs to have 3d kernels of depth <span class="math-container">$k$</span>: this is the main <em>requirement</em> in the case of 2d convolutions (in the case of 3d convolutions, the kernels can have a different depth than the input 3d volume, but you can ignore this for now!).</p>
  <p>Another thing that you need to take care of is the <strong>padding</strong> that you can add around this 3d volume. This, along with the <strong>stride</strong> (i.e. the step with which you move the kernel), determines the height and width of the output of the convolutional layer.</p>
  <p>So, to recapitulate, what you have to do is set the depth of the kernels in the convolutional layer <span class="math-container">$l+1$</span> to be equal to the number of kernels that you use in the convolutional layer <span class="math-container">$l$</span>. So, let's say that the number of kernels is a hyper-parameter (note that this is usually the case!), and that the user sets the number of kernels <span class="math-container">$k=8$</span> in the convolutional layer <span class="math-container">$l$</span>, and, for simplicity, assume that all kernels are <span class="math-container">$3 \times 3$</span>, then, in layer <span class="math-container">$l$</span>, you will perform <span class="math-container">$8$</span> convolutions, one for each kernel. These <span class="math-container">$8$</span> convolutions produce a 3d array of dimensions <span class="math-container">$w \times h \times 8$</span> (where <span class="math-container">$w$</span> and <span class="math-container">$h$</span> depend on the dimensions of the input to layer <span class="math-container">$l$</span>, the stride, and padding). Consequently, in the convolutional layer <span class="math-container">$l+1$</span>, the kernels need to be <span class="math-container">$3 \times 3 \times 8$</span>.</p>
  <p>If it's the pooling layer that produces the 3d array to be passed to the next convolutional layer, you should still set the depth of the kernels in the convolutional layer <span class="math-container">$l+1$</span> to the number of kernels in the convolutional layer <span class="math-container">$l$</span> (provided that, in the pooling layer, you only redimension the width and height of the 3d array, which is usually the case).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-10T15:24:58.410Z
Answers.LastActivityDate: 2021-01-10T17:51:42.047Z
Answers.LastEditDate: 2021-01-10T17:51:42.047Z
Answers.UserDisplayName: nbro
Body: <p>I am currently trying to write a CNN from scratch, but I don't understand how to feed the information from a max-pooling layer to the next convolutional layer. Specifically, I don't know what to do with the 6 filtered and pooled images from the first convolutional and max-pooling layers. How do I feed those images into the next convolutional layer?</p>
  
Tags: <convolutional-neural-networks><implementation><convolutional-layers><pooling>
Title: How do you pass the image from one convolutional layer to another in a CNN?
UserDisplayName: Sean Mabli
ThreadText: # How do you pass the image from one convolutional layer to another in a CNN?
  
  (Asked by: username_0 on 2021-01-10)
  
  I am currently trying to write a CNN from scratch, but I don't understand how to feed the information from a max-pooling layer to the next convolutional layer. Specifically, I don't know what to do with the 6 filtered and pooled images from the first convolutional and max-pooling layers. How do I feed those images into the next convolutional layer?
  
  **Tags:** convolutional-neural-networks, implementation, convolutional-layers, pooling
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-10. Score: 1
  
  The application of 1 kernel (aka filter) to an input (with a 2d convolution) is a matrix (a 2d array), which is often known as a **feature map** (aka activation map). The application of $k$ kernels to the same input is a 3d array (sometimes called *tensor*, though this may not be exactly correct, or 3d *volume*) with depth $k$, i.e. you have $k$ concatenated feature maps. This 3d array is the input to the next convolutional layer, which needs to have 3d kernels of depth $k$: this is the main *requirement* in the case of 2d convolutions (in the case of 3d convolutions, the kernels can have a different depth than the input 3d volume, but you can ignore this for now!).
  
  Another thing that you need to take care of is the **padding** that you can add around this 3d volume. This, along with the **stride** (i.e. the step with which you move the kernel), determines the height and width of the output of the convolutional layer.
  
  So, to recapitulate, what you have to do is set the depth of the kernels in the convolutional layer $l+1$ to be equal to the number of kernels that you use in the convolutional layer $l$. So, let's say that the number of kernels is a hyper-parameter (note that this is usually the case!), and that the user sets the number of kernels $k=8$ in the convolutional layer $l$, and, for simplicity, assume that all kernels are $3 \times 3$, then, in layer $l$, you will perform $8$ convolutions, one for each kernel. These $8$ convolutions produce a 3d array of dimensions $w \times h \times 8$ (where $w$ and $h$ depend on the dimensions of the input to layer $l$, the stride, and padding). Consequently, in the convolutional layer $l+1$, the kernels need to be $3 \times 3 \times 8$.
  
  If it's the pooling layer that produces the 3d array to be passed to the next convolutional layer, you should still set the depth of the kernels in the convolutional layer $l+1$ to the number of kernels in the convolutional layer $l$ (provided that, in the pooling layer, you only redimension the width and height of the 3d array, which is usually the case).
  
  
  ---
  
  