I have two tensors in my forward function with sizes torch.Size([64, 256] where the 64 is the batch size. I would like to compute the L2 distance between the two tensors/vectors.
So, I have:
a=torch.randn(64,256)
b=torch.randn(64,256)
I am able to do something like:
dist=torch.abs(b-a) # yields shape 64,256 which is the expected output
However, this seems too naive and I was wondering if there was a better distance measure I can use here which gives me back a 64,256 sized tensor (since I feed this into a linear layer).
I tried using PairwiseDistance but this gives me a back a tensor of size 256, instead of 64,256.
Any pointers would be great.