Questions tagged [max-pooling]

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

122 questions
1
vote
0 answers

How to efficiently pairwise pool a tensor by trace value in Pytorch?

I have a pytorch tensor T with shape (batch_size, window_size, filters, 3, 3) and I would like to pool the tensor by trace. Specifically, I would like to obtain a tensor T_pooled of size (batch_size, window_size//2, filters, 3, 3) by comparing the…
user530316
  • 49
  • 4
1
vote
1 answer

Understanding average (sum) pooling padding in keras

I have a simple sum pooling implemented in keras tensorflow, using AveragePooling2D*N*N, so it creates a sum of the elements in pool with some shape, same padding so the shape won't change: import numpy as np import seaborn as sns import…
Ruli
  • 2,184
  • 10
  • 21
  • 30
1
vote
2 answers

I want to use Conv1D and MaxPool1D in pytorch for a 3-d tensor to its third dimension

For example, there is a 3-d tensor, I want to run the conv1d calculation on its third dimension, import torch import torch.nn as nn x = torch.rand(4,5,6) conv1d =nn.Conv1d(in_channels=1,out_channels=2,kernel_size=5,stride=3,padding=0) y =…
1
vote
1 answer

ValueError: Input 0 of layer sequential_9 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, None, None]

I'm trying to solve classification problem. I don't know why I'm getting this error: ValueError: Input 0 of layer sequential_9 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, None, None] This is the…
Edayildiz
  • 505
  • 1
  • 9
1
vote
1 answer

Keras MaxPooling3D not allowed

I'm trying to build a CNN and got stuck with MaxPooling3D layers not working. Both layers get an input shape of (1, 5, 32) and I'd like to max-pool over the depth using poolsize (1, 1, 32) so the output becomes of shape (1, 5, 1). However this…
Henk
  • 71
  • 8
1
vote
0 answers

Can i use both dilated convolution and maxpooling layer both at the same time?

In my DCNN architecture, where I am using a dilation factor of '2' in each convolution layer and the Maxpooling Layer.I am using both in concatenation. Though it is improving my accuracy, but I am thinking is it right to do so? As in dilation we…
1
vote
1 answer

How to optimize this MaxPool2d implementation

I made some implementations of MaxPool2d(Running correctly, comparing with a pytorch). When testing this on a mnist dataset, this function(updateOutput) takes a very long time to complete. How to optimize this code using numpy? class…
1
vote
1 answer

How to add pooling layer to BERT QA for large text

I'm trying to implement a Question answering system that deal with large input text: so the idea is to split the large input text into subsequences of 510 tokens, after I will generate the representation of each sequence independently and using a…
1
vote
1 answer

Maxpool of an image in pytorch

I'm trying to just apply maxpool2d (from torch.nn) on a single image (not as a maxpool layer). Here is my code right now: name = 'astronaut' imshow(images[name], name) img = images[name] # pool of square window of size=3, stride=1 m =…
user11764168
1
vote
0 answers

PyTorch MaxPool2D unexpected behavior with padding=1

I was playing around with MaxPool2D in PyTorch and discovered strange behavior when setting padding=1. Here is what I got: Code: import torch from torch.nn.functional import max_pool2d TEST = 1 def test_maxpool(negative=False, tnsr_size=2,…
trsvchn
  • 4,526
  • 3
  • 15
  • 27
1
vote
1 answer

Batch Normalization when CNN with only 2 ConvLayer?

I wonder if it is a problem to use BatchNormalization when there are only 2 convolutional layers in a CNN. Can this have adverse effects on classification performance? Now I don't mean the training time, but really the accuracy? Is my network…
1
vote
2 answers

How do covolution2d and maxpolling2d apply on input in Keras?

I'm new to all the stuff I'm going to talking about so that the questions may be too simple. Thanks in advance for your answers! My questions cames from the following image: To be more clear: For the first Convolution, from 1 x 28 x28 to 25 x 26…
1
vote
1 answer

Max pool a single image in tensorflow using "tf.nn.avg_pool"

I want to apply "tf.nn.max_pool()" on a single image but I get a result with dimension that is totally different than the input: import tensorflow as tf import numpy as np ifmaps_1 = tf.Variable(tf.random_uniform( shape=[ 7, 7, 3], minval=0,…
mnabil
  • 496
  • 1
  • 3
  • 13
1
vote
2 answers

tf.keras embedding with mask_zero=True followed by GlobalAveragePooling1D generate TypeError

I am on tensorflow v2 on google colab using tf.keras. I am trying to use embedding with masking follow by global average. Here's my code: vocab_size = 1500 inputs = Input(shape=(None,), dtype=tf.int32, name='word_sequence') x =…
kawingkelvin
  • 2,229
  • 1
  • 17
  • 35
1
vote
1 answer

strides should be of length 1, 1 or 3 but was 2

I have been trying to stack Convolutional neural networks with GRUs for an image to text problem. Here's my model : model=Sequential() model.add(TimeDistributed(Conv2D(16,kernel_size (3,3),data_format="channels_last",input_shape=…
user45788
  • 11
  • 1
  • 2
1 2
3
8 9