How can I reduce a tensor's last dimension in PyTorch?
I have tensor of shape (1, 3, 256, 256, 3). I need to reduce one of the dimensions to obtain the shape (1, 3, 256, 256). How can I do it? 

Thanks!

If you intend to apply mean over the last dimension, then you can do so with:

In [18]: t = torch.randn((1, 3, 256, 256, 3))

In [19]: t.shape
Out[19]: torch.Size([1, 3, 256, 256, 3])

# apply mean over the last dimension
In [23]: t_reduced = torch.mean(t, -1)

In [24]: t_reduced.shape
Out[24]: torch.Size([1, 3, 256, 256])

# equivalently
In [32]: torch.mean(t, t.ndimension()-1).shape
Out[32]: torch.Size([1, 3, 256, 256])

