Solved by ptrblck in post #2 
              
              
                Your code looks alright. 
Alternatively, since your desired output shape after the average pooling operation is [batch_size, 512, 13, 1, 1], you could also directly apply the mean() operation on dim3 and dim4 in a similar way as you’ve already done for torch.max (but this should yield the same outpu…