Pytorch sum tensors doing an operation within each set of numbers
I have the following Pytorch tensor:

V1 = torch.tensor([[2, 4], [6, 4], [5, 3]])


I want to do the sum of the difference of each pair of numbers (applying absolute value), something like the code below;

result.sum(abs(2-4), abs(6-4), abs(5-3))


I can do this using a for statement:

total = 0
for i in range(0,vector.size(0)):
    total = total + torch.abs(vector.data[i][1] - vector.data[i][0])


But I want to do it without using a for.

Is there a way to do that?

You can do 

torch.abs(V1[:, 1]- V1[:, 0])

and to sum over it 

torch.sum(torch.abs(V1[:, 1]- V1[:, 0]))
