Rate this Page
โ˜… โ˜… โ˜… โ˜… โ˜…

torch.dot#

torch.dot(input, tensor, *, out=None) โ†’ Tensor#

Computes the dot product of two 1D tensors.

Note

Unlike NumPyโ€™s dot, torch.dot intentionally only supports computing the dot product of two 1D tensors with the same number of elements.

Parameters
  • input (Tensor) โ€“ first tensor in the dot product, must be 1D.

  • tensor (Tensor) โ€“ second tensor in the dot product, must be 1D.

Keyword Arguments

out (Tensor, optional) โ€“ the output tensor.

Example:

>>> torch.dot(torch.tensor([2, 3]), torch.tensor([2, 1]))
tensor(7)

>>> t1, t2 = torch.tensor([0, 1]), torch.tensor([2, 3])
>>> torch.dot(t1, t2)
tensor(3)