Answers.Body: <p>It isn't strictly necessary, but it makes the model simpler and more robust. Global pooling (be it <code>average</code> or <code>max</code> pooling) makes it so, that the network's prediction is very invariant to image cropping / translation / scaling. This is because the pooling step loses all spatial information, it only preserves the global statistic on each output feature.</p>
  <p>But on some problems it is beneficial to keep some spatial information, and use a &quot;normal&quot; pooling layer to scale the output image from let's say a shape of <code>(128, 128, 64)</code> to <code>(4, 4, 64)</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-18T13:16:23.430Z
Answers.Text: If I understand it correctly, the pooling mechanism described can also be used to work with images that vary in size and shape, and still output a fixed size which will then feed a fixed size fully-connected layer. I would expect that to be a key use-case?
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-18T13:42:05.037Z
Answers.Text: Yes that would work as well, then the network would work without having to crop or scale each input image to a specific size. This might be easier to do in some frameworks than others. At least in Keras I'm used to use networks with fixed input size. But if the input has vastly different scale, I expect that the performance is poor since features such as textures and other complex shapes would have different scale than in the training data.
Answers.UserDisplayName: NikoNyrh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-19T06:19:28.877Z
Answers.Text: If we don't use global pooling, it is more likely to face overfitting problem due to an extensive amount of parameters in FC layers. For example, in the case
  of 1000-class classification using the ResNet-18 model, the parameter count in the FC layer would be 7*7*512*1000=  25,088,000, if we don't use global pooling after the last convolutional layer.
Answers.UserDisplayName: Liuji
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-19T07:00:29.833Z
Answers.Text: I think the problem wouldn't be alleviated too much even if "normal" pooling layers are employed. Note that "normal" pooling layers have been already used in ResNet models, but all ResNet models still use global pooling at the end of the network.
Answers.UserDisplayName: Liuji
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-18T12:56:51.237Z
Answers.LastActivityDate: 2023-12-18T12:56:51.237Z
Answers.UserDisplayName: NikoNyrh
Body: <p>In many image classification models, the global pooling operation is performed before the classification layer (i.e. fully connected layer) to reduce model complexity. Is the global pooling layer a necessary component in the image classification framework?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-18T08:38:06.107Z
Comments.Text: Welcome to AI Stack Exchange. I am not sure what you mean by "global pooling", it's not a standard term. Could you perhaps identify which layer you mean from a reference implementation?
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-18T11:13:22.203Z
Comments.Text: I think he is talking about global average pooling...
Comments.UserDisplayName: Hiren Namera
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-18T12:50:00.273Z
Comments.Text: There is also global max pooling. This term is used at least in the Tensorflow / Keras framework.
Comments.UserDisplayName: NikoNyrh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-19T06:09:39.547Z
Comments.Text: @NeilSlater Thanks for you reply. I think global pooling was firstly introduced in the paper 《network in network》. It is commonly located before fully connected layers.
Comments.UserDisplayName: Liuji
Tags: <neural-networks><machine-learning><deep-learning><computer-vision><image-recognition>
Title: Is global pooling necessary in image classification models?
UserDisplayName: Liuji
ThreadText: # Is global pooling necessary in image classification models?
  
  (Asked by: username_0 on 2023-12-18)
  
  In many image classification models, the global pooling operation is performed before the classification layer (i.e. fully connected layer) to reduce model complexity. Is the global pooling layer a necessary component in the image classification framework?
  
  **Tags:** neural-networks, machine-learning, deep-learning, computer-vision, image-recognition
  
  > **Comments:**
  > **username_1**: Welcome to AI Stack Exchange. I am not sure what you mean by "global pooling", it's not a standard term. Could you perhaps identify which layer you mean from a reference implementation?  
  > **username_2**: I think he is talking about global average pooling...  
  > **username_3**: There is also global max pooling. This term is used at least in the Tensorflow / Keras framework.  
  > **username_0**: @username_1 Thanks for you reply. I think global pooling was firstly introduced in the paper 《network in network》. It is commonly located before fully connected layers.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2023-12-18. Score: 1
  
  It isn't strictly necessary, but it makes the model simpler and more robust. Global pooling (be it `average` or `max` pooling) makes it so, that the network's prediction is very invariant to image cropping / translation / scaling. This is because the pooling step loses all spatial information, it only preserves the global statistic on each output feature.
  
  But on some problems it is beneficial to keep some spatial information, and use a "normal" pooling layer to scale the output image from let's say a shape of `(128, 128, 64)` to `(4, 4, 64)`.
  
  > **Comments:**
  > **username_1**: If I understand it correctly, the pooling mechanism described can also be used to work with images that vary in size and shape, and still output a fixed size which will then feed a fixed size fully-connected layer. I would expect that to be a key use-case?  
  > **username_3**: Yes that would work as well, then the network would work without having to crop or scale each input image to a specific size. This might be easier to do in some frameworks than others. At least in Keras I'm used to use networks with fixed input size. But if the input has vastly different scale, I expect that the performance is poor since features such as textures and other complex shapes would have different scale than in the training data.  
  > **username_0**: If we don't use global pooling, it is more likely to face overfitting problem due to an extensive amount of parameters in FC layers. For example, in the case of 1000-class classification using the ResNet-18 model, the parameter count in the FC layer would be 7*7*512*1000=  25,088,000, if we don't use global pooling after the last convolutional layer.  
  > **username_0**: I think the problem wouldn't be alleviated too much even if "normal" pooling layers are employed. Note that "normal" pooling layers have been already used in ResNet models, but all ResNet models still use global pooling at the end of the network.  
  
  ---
  
  