• 文档 >
  • torch >
  • torch.dist
快捷键

torch.dist

torch.dist(input, other, p=2) Tensor

返回( input - other )的 p 范数

inputother 的形状必须可广播。

参数:
  • input (Tensor) – 输入张量。

  • 其他(张量)- 右侧输入张量

  • p(浮点数,可选)- 要计算的范数

示例:

>>> x = torch.randn(4)
>>> x
tensor([-1.5393, -0.8675,  0.5916,  1.6321])
>>> y = torch.randn(4)
>>> y
tensor([ 0.0967, -1.0511,  0.6295,  0.8360])
>>> torch.dist(x, y, 3.5)
tensor(1.6727)
>>> torch.dist(x, y, 3)
tensor(1.6973)
>>> torch.dist(x, y, 0)
tensor(4.)
>>> torch.dist(x, y, 1)
tensor(2.6537)

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源