I have an input tensor like x = torch.rand(2,3,13,224,224) and after passing through this tensor from my model I get an output shape as torch.Size([2, 512, 13, 14, 14]). I then further want to reduce 14x14 to 1x1 so it looks like this torch.Size([2, 512, 13, 1, 1]) and then have a max of the 13 features to get an output tensor like torch.Size([2, 512, 1, 1, 1]).
I am pretty new to PyTorch and I found way to do this,
gap = torch.nn.AdaptiveAvgPool3d((None,1,1))
x = model(torch.rand(2,3,13,224,224))
x = gap(x)
x = torch.max(x, 2, keepdim=True)[0]
I want to know if this is the correct way to do this or not. I want to reduce all the 14x14 values to 1x1 using average pooling, my question is am i using AdaptiveAvgPool3d in a correct way or should I use AdaptiveAvgPool2d in some way for reducing 14x14?