Answers.Body: <p>The result from applying a max pooling layer with a stride that does not exactly fit to the input will be dependent on the implementation in your library.</p>
  <p>Assuming stride 2, and pool size (2,2), in your case the most likely things are:</p>
  <ul>
  <li><p>The result will round up, so you will have a feature map layer with dimensions <code>(11, 11, num_filters)</code> although the right edge pixels will be a max over 2 pixels in the input, and the right bottom corner will just be a copy of the right bottom corner in the input (counting from top left as <span class="math-container">$(0, 0)$</span>)</p>
  </li>
  <li><p>It is an error condition for your libary.</p>
  </li>
  </ul>
  <p>If it is not an error, then the max pooling should still perform the task it was intended to. If important features are often at the right or bottom edge, then they may generalise slightly less well, but you probably won't notice a measurable effect.</p>
  <p>You could experiment with different sizes of pooling, different strides, or padding the previous convolutional layer so that the max pooling fits exactly. You will have to do something like this if the library has errors when the pooling does not fit exactly. You can test your experiments using cross validation, to see if there is any measurable difference.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-02T14:27:47.330Z
Answers.LastActivityDate: 2020-09-03T13:48:34.753Z
Answers.LastEditDate: 2020-09-03T13:48:34.753Z
Answers.UserDisplayName: Neil Slater
Body: <p>I'm trying to white board the different mechanisms behind a convolutional neural network.
  I have on question regarding the dimension of my volume after using a max pooling layer.
  Let's suppose I have a (21,21,#filtres) volume's dimension. If Max Pooling divide by 2 the height and width of my volume, what will be the dimension after the Max Pooling layer ?
  If odd numbers are a problem when using max pooling layer, How do I fix it ?</p>
  <p>Thank you !</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-02T14:15:23.270Z
Comments.Text: Are you considering the `stride` parameter (available in most libraries)? If so, what is it set to? The default would be to set stride equal to the pooling size i.e. 2, and therefore divide layer size by 2.
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-02T14:31:04.120Z
Comments.Text: From the lectures I followed, stride was often set to 1. Make it equal to 2 will fix the problem ?
Comments.UserDisplayName: Valentin
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-02T14:32:51.123Z
Comments.Text: If stride is set to 1 there is no problem, the pooling will not need to be applied partially in order to cover the whole input. Your output would be `(20, 20, num_filters)` though, it doesn't shrink the feature map as much. It still provides useful generalisation. Stride is often set to `1` for the convolutional layer, but not for pooling layers, so it may be the value you noticed from lectures was referring convolutional layers.
Comments.UserDisplayName: Neil Slater
Tags: <neural-networks><deep-learning><convolutional-neural-networks>
Title: What is the dimension of my output of the form (2n + 1, 2n + 1, #filters) after a MaxPooling layer
UserDisplayName: Valentin
ThreadText: # What is the dimension of my output of the form (2n + 1, 2n + 1, #filters) after a MaxPooling layer
  
  (Asked by: username_0 on 2020-09-02)
  
  I'm trying to white board the different mechanisms behind a convolutional neural network.
  I have on question regarding the dimension of my volume after using a max pooling layer.
  Let's suppose I have a (21,21,#filtres) volume's dimension. If Max Pooling divide by 2 the height and width of my volume, what will be the dimension after the Max Pooling layer ?
  If odd numbers are a problem when using max pooling layer, How do I fix it ?
  
  Thank you !
  
  **Tags:** neural-networks, deep-learning, convolutional-neural-networks
  
  > **Comments:**
  > **username_1**: Are you considering the `stride` parameter (available in most libraries)? If so, what is it set to? The default would be to set stride equal to the pooling size i.e. 2, and therefore divide layer size by 2.  
  > **username_0**: From the lectures I followed, stride was often set to 1. Make it equal to 2 will fix the problem ?  
  > **username_1**: If stride is set to 1 there is no problem, the pooling will not need to be applied partially in order to cover the whole input. Your output would be `(20, 20, num_filters)` though, it doesn't shrink the feature map as much. It still provides useful generalisation. Stride is often set to `1` for the convolutional layer, but not for pooling layers, so it may be the value you noticed from lectures was referring convolutional layers.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-09-02. Score: 1
  
  The result from applying a max pooling layer with a stride that does not exactly fit to the input will be dependent on the implementation in your library.
  
  Assuming stride 2, and pool size (2,2), in your case the most likely things are:
  
  * The result will round up, so you will have a feature map layer with dimensions `(11, 11, num_filters)` although the right edge pixels will be a max over 2 pixels in the input, and the right bottom corner will just be a copy of the right bottom corner in the input (counting from top left as $(0, 0)$)
  * It is an error condition for your libary.
  
  If it is not an error, then the max pooling should still perform the task it was intended to. If important features are often at the right or bottom edge, then they may generalise slightly less well, but you probably won't notice a measurable effect.
  
  You could experiment with different sizes of pooling, different strides, or padding the previous convolutional layer so that the max pooling fits exactly. You will have to do something like this if the library has errors when the pooling does not fit exactly. You can test your experiments using cross validation, to see if there is any measurable difference.
  
  
  ---
  
  