How to calculate L2 distance between torch.Tensor without Variable?

Is there a function to do this?

2 Likes

torch.norm(tensor, 2)

1 Like

I mean calculate between 2 tensors.
e.g.
(1, 0) and (1 ,1) is sqrt((1-1)^2 + (1-0)^2)

torch.dist() is ok, I found answer.

4 Likes

sorry for my carelessnesss and misunderstanding .Very happy you got the right answer!

1 Like

torrch.dist(x, y, p) is the same as torch.norm(x - y, p) …

1 Like

How can you calculate the distances for the list of points pair such as a=[ [1,1,1], [2,2,2]], b=[[3,3,3], [4,4,4]] ?