Relative Content

Tag Archive for pythonpytorchtorcheuclidean-distancenorm

Torch Euclidian Norm (L2)

I am trying to compute the L2 norm between two tensors as part of a loss function, but somehow my loss ends up being NaN and I suspect it it because of the way the L2 norm is computed. Can you please explain me the difference between torch.linalg.vector_norm(x-y) and torch.norm(x-y) functions? I think that the x-y difference is getting to small and I want to make sure that these functions handle this case properly.

Torch Euclidian Norm (L2)

I am trying to compute the L2 norm between two tensors as part of a loss function, but somehow my loss ends up being NaN and I suspect it it because of the way the L2 norm is computed. Can you please explain me the difference between torch.linalg.vector_norm(x-y) and torch.norm(x-y) functions? I think that the x-y difference is getting to small and I want to make sure that these functions handle this case properly.