Spec-Zone.ru › PyTorch 2

torch.dist

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

Возвращает p-норму (input - other)

Формы input и other должны быть совместимы для трансляции.

Параметры
  • input (Tensor) – тензор входных данных.
  • other (Tensor) – тензор правого входного значения
  • p (float, необязательно) – норма, которая должна быть вычислена

Пример:

>>> 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)

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.dist.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API