Torch tensor dimensionality

import torch
x = torch.randn(10,1000)
x.shape
torch.Size([10, 1000])

Mean of each row at the time in tensor form

y = x.mean(1)[:, None]
y.shape
torch.Size([10, 1])

Mean each row at the time in vector form

z = x.mean(1)
z.shape
torch.Size([10])

Re-arange matrix dimensions

torch.arange(0,6).view(2,3)
tensor([[0, 1, 2],
        [3, 4, 5]])