Hi all,
I want to calculate the l2 distance among all elements of two vector. naive version code is:
import torch
n = 4
d = 2
A = torch.randn(n,d)
B = torch.randn(n,d)
C = torch.zeros(n,n)

for i in range(n):
    for j in range(n):
        C[i][j] = torch.sum(torch.sqrt((A[i] - B[j])*(A[i]-B[j])))

I want to ask is there any easier way to do this calculation at PyTorch?
Thanks!
Jun