PyTorch torch.dot Funktion
PyTorch torch-Referenzhandbuch
torch.dotEs ist eine Funktion in PyTorch, die verwendet wird, um das Skalarprodukt zweier Vektoren zu berechnen.
Funktionsdefinition
torch.dot(input, other, out)
Anwendungsbeispiel
Beispiel
import torch
a = torch.tensor([1, 2, 3])
b = torch.tensor([4, 5, 6])
# Skalarprodukt: 1*4 + 2*5 + 3*6 = 32
result = torch.dot(a, b)
print(result)
a = torch.tensor([1, 2, 3])
b = torch.tensor([4, 5, 6])
# Skalarprodukt: 1*4 + 2*5 + 3*6 = 32
result = torch.dot(a, b)
print(result)
Die Ausgabe ist:
tensor(32)
Andere Erweiterungen