For questions about max pooling (as well as average pooling) operation, commonly used in convolutional neural networks for downsampling.
Questions tagged [max-pooling]
122 questions
51
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
- 669
- 1
- 5
- 9
44
votes
5 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,346
- 2
- 14
- 28
33
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,474
- 1
- 15
- 21
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
- 740
- 17
12
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,159
- 3
- 16
- 29
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
- 3,240
- 4
- 25
- 54
8
votes
1 answer
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,532
- 2
- 23
- 35
8
votes
0 answers
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…
x3t2h
- 81
- 3
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
- 633
- 1
- 5
- 10
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,…
Gretel_f
- 175
- 6
6
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
- 7,574
- 4
- 37
- 93
5
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),…
Code Now
- 511
- 5
- 14
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…
James Oliver
- 397
- 2
- 11
4
votes
1 answer
How to select top-k elements of a keras dense layer?
I'm trying to perform a k-max pooling in order to select top-k elements of a dense with shape (None, 30). I tried a MaxPooling1D layer but it doesn't work, since keras pooling layers require at least a 2d input shape. I'm using the following Lambda…
Belkacem Thiziri
- 483
- 1
- 6
- 23
3
votes
2 answers
Pytorch: a similar process to reverse pooling and replicate padding?
I have a tensor A that has shape (batch_size, width, height). Assume that it has these values:
A = torch.tensor([[[0, 1],
[1, 0]]])
I am also given a number K that is a positive integer. Let K=2 in this case. I want to do a…
AerysS
- 1,165
- 6
- 18