Is it possible to apply pooling across the channel dimension of the input tensor?

I have an input tensor of the shape (32, 256, 256, 256). In this tensor shape, 32 is the batch size. second 256 is the number of channels in the given image of size 256 X 256.

I want to do pooling in order to convert the tensor into the shape(32, 32, 256, 256). In PyTorch, if I try to apply the pooling then the last two dimensions of the shape, related to the image, are changing, but not the dimension related to the channel.

Is it possible to apply pooling on the input tensor to obtain the output tensor? If not possible, what are the recommended options for me to convert the input tensor into the output tensor?

Topic pooling image-preprocessing reshape pytorch

Category Data Science


I don't think what you want to do can be done by a pooling layer, but it might be possible by using a "convolutional layer" with 32 filters. You need to use proper padding and stride, such as discussed in this post to preserve size.

And if you want to mimic pooling, you may need to use a custom layer with no activation function (or linear activation). The parameters in the layer needs to be set to non-trainable, and initialized by hand.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.