Can I get another tensor from input by the dim of cols?

a = torch.randn(3,2)

for example:

tensor([[ 0.5957,  1.6250],
        [-0.4354,  2.0719],
        [ 0.8076, -1.2720]])

and a[1] = tensor([-0.4354, 2.0719]), but I want to get the cols’ data of a,
such as tensor([1.6250,2.0719,-1.2720]), what shoud I do? thanks for your help!

You could index in the second dimension:

a[:, 1]
1 Like

thanks for your reply!