oneflow.nn.functional.pairwise_distance¶
-
oneflow.nn.functional.
pairwise_distance
(x1: Tensor, x2: Tensor, dim: float = 2.0, eps: float = 1e-06, keepdim: bool = False) → Tensor¶ Computes the pairwise distance between vectors \(v_1\), \(v_2\) using the p-norm:
\[\left \| x \right \| _p = (\sum_{i=1}^n \left | x_i \right |^p )^{\frac{1}{p}}\]The interface is consistent with PyTorch. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.nn.PairwiseDistance.html.
- Parameters
For example:
>>> import oneflow as flow >>> x1 = flow.arange(12).reshape(3, 4) >>> x2 = flow.arange(12).reshape(3, 4) >>> output = flow.nn.functional.pairwise_distance(x1, x2, p=2) >>> output tensor([2.0000e-06, 2.0000e-06, 2.0000e-06], dtype=oneflow.float32) >>> output.shape oneflow.Size([3])