PyTorch torch.mm Funktion
PyTorch torch Referenzhandbuch
torch.mmist eine Funktion in PyTorch, die zur zweidimensionalen Matrixmultiplikation verwendet wird.
Funktionsdefinition
torch.mm(input, mat2, out)
Anwendungsbeispiel
Beispiel
import torch
A = torch.randn(2, 3)
B = torch.randn(3, 4)
# Matrizenmultiplikation
C = torch.mm(A, B)
print("A-Form:", A.shape)
print("B-Form:", B.shape)
print("C-Form:", C.shape)
A = torch.randn(2, 3)
B = torch.randn(3, 4)
# Matrizenmultiplikation
C = torch.mm(A, B)
print("A-Form:", A.shape)
print("B-Form:", B.shape)
print("C-Form:", C.shape)
Das Ausgabeergebnis ist:
A 形状: torch.Size([2, 3]) B 形状: torch.Size([3, 4]) C 形状: torch.Size([2, 4])
Andere Erweiterungen