Questions tagged [max-pooling]

For questions about max pooling (as well as average pooling) operation, commonly used in convolutional neural networks for downsampling.

157 questions
59
votes
9 answers

how to perform max/mean pooling on a 2d array using numpy

Given a 2D(M x N) matrix, and a 2D Kernel(K x L), how do i return a matrix that is the result of max or mean pooling using the given kernel over the image? I'd like to use numpy if possible. Note: M, N, K, L can be both even or odd and they need not…
rapidclock
  • 1,677
  • 2
  • 17
  • 32
54
votes
2 answers

What is the difference between Keras' MaxPooling1D and GlobalMaxPooling1D functions?

Both MaxPooling1D and GlobalMaxPooling1D are described as a max pooling operation for temporal data. keras.layers.pooling.MaxPooling1D(pool_size=2, strides=None, padding='valid') I understand that GlobalMaxPooling1D takes no input parameters.…
KayBay
  • 719
  • 1
  • 7
  • 10
37
votes
1 answer

Max pool layer vs Convolution with stride performance

In most of the architectures, conv layers are being followed by a pooling layer (max / avg etc.). As those pooling layers are just selecting the output of previous layer (i.e. conv), can we just use convolution with stride 2 and expect the similar…
Deniz Beker
  • 1,984
  • 1
  • 18
  • 22
15
votes
7 answers

numpy create array of the max of consecutive pairs in another array

I have a numpy array: A = np.array([8, 2, 33, 4, 3, 6]) What I want is to create another array B where each element is the pairwise max of 2 consecutive pairs in A, so I get: B = np.array([8, 33, 33, 4, 6]) Any ideas on how to implement? Any ideas…
GalSuchetzky
  • 785
  • 5
  • 21
15
votes
1 answer

Backpropagation for Max-Pooling Layers: Multiple Maximum Values

I am currently implementing a CNN in plain numpy and have a brief question regarding a special case of the backpropagation for a max-pool layer: While it is clear that the gradient with respect to non-maximum values vanishes, I am not sure about the…
15
votes
2 answers

Pooling vs Pooling-over-time

I understand conceptually what is happening in a max/sum pool as a CNN layer operation, but I see this term "max pool over time", or "sum pool over time" thrown around (e.g., "Convolutional Neural Networks for Sentence Classification" paper by Yoon…
Matt
  • 1,599
  • 3
  • 21
  • 33
9
votes
2 answers

In PyTorch's "MaxPool2D", is padding added depending on "ceil_mode"?

In MaxPool2D the padding is by default set to 0 and the ceil_mode is also set to False. Now, if I have an input of size 7x7 with kernel=2,stride=2 the output shape becomes 3x3, but when I use ceil_mode=True, it becomes 4x4, which makes sense because…
paul-shuvo
  • 1,874
  • 4
  • 33
  • 37
9
votes
2 answers

TensorFlow: Why does avg_pool ignore one stride dimension?

I am attempting to stride over the channel dimension, and the following code exhibits surprising behaviour. It is my expectation that tf.nn.max_pool and tf.nn.avg_pool should produce tensors of identical shape when fed the exact same arguments. This…
oarfish
  • 4,116
  • 4
  • 37
  • 66
8
votes
2 answers

What is output tensor of Max Pooling 2D Layer in TensorFlow?

I was trying to understand some basics about the tensorflow and I got stuck while reading documentation for max pooling 2D layer: https://www.tensorflow.org/tutorials/layers#pooling_layer_1 This is how max_pooling2d is specified: pool1 =…
Nikola Stojiljkovic
  • 693
  • 1
  • 5
  • 11
7
votes
1 answer

Keras Model with Maxpooling1D and channel_first

I have a problem with my current attempt to build a sequential model for time series classification in Keras. I want to work with channels_first data, because it is more convenient from a perprocessing perspective (I only work with one channel,…
7
votes
2 answers

hybrid of max pooling and average pooling

While tweaking a deep convolutional net using Keras (with the TensorFlow backend) I would like to try out a hybrid between MaxPooling2D and AveragePooling2D, because both strategies seem to improve two different aspects regarding my objective. I'm…
Tobias Hermann
  • 9,936
  • 6
  • 61
  • 134
5
votes
1 answer

Pooling over channels in pytorch

In tensorflow, I can pool over the depth dimension which would reduce the channels and leave the spatial dimensions unchanged. I'm trying to do the same in pytorch but the documentation seems to say pooling can only be done over the height and width…
Judy T Raj
  • 1,755
  • 3
  • 27
  • 41
5
votes
2 answers

Does omitting pooling layers in CNNs make sense in some cases?

I know that a usual CNN consists of both convolutional and pooling layers. Pooling layers make the output smaller which means less computations and they also make it somehow transform invariant, so the position of the feature from the kernel filter…
4
votes
1 answer

Is maxpooling on odd number possible?

I am going through the Udacity DeepLearning Nanodegree and working on the autoencoder mini project. I do not understand the solution, nor how to check it myself. So this is 2 questions. We start with 28*28 images. These are fed through 3…
4
votes
2 answers

Does MaxPooling reduce overfitting?

I have trained the following CNN model with a smaller data set, therefore it does overfitting: model = Sequential() model.add(Conv2D(32, kernel_size=(3,3), input_shape=(28,28,1),…
1
2 3
10 11