PyTorch torch.mm function
PyTorch torch reference manual
torch.mm is a function in PyTorch used to perform two-dimensional matrix multiplication.
Function definition
torch.mm(input, mat2, out)
Usage examples
Example
import
torch
A
=
torch.
randn
(
2
,
3
)
B
=
torch.
randn
(
3
,
4
)
Matrix multiplication
C
=
torch.
mm
(
A
,
B
)
(
"A shape:"
,
A.
shape
)
(
"B shape:"
,
B.
shape
)
(
"C shape:"
,
C.
shape
)
The output is:
A 形状: torch.Size([2, 3])
B 形状: torch.Size([3, 4])
C 形状: torch.Size([2, 4])