PyTorch torch.bmm function
PyTorch torch reference manual
torch.bmm is a function in PyTorch used to perform batched matrix multiplication.
Function definition
torch.bmm(input, mat2, out)
Usage examples
Example
import
torch
Batched matrix multiplication
batch_a
=
torch.
randn
(
10
,
3
,
4
)
batch_b
=
torch.
randn
(
10
,
4
,
5
)
result
=
torch.
bmm
(
batch_a
,
batch_b
)
(
"Batched result shape:"
,
result.
shape
)
The output is:
批量结果形状: torch.Size([10, 3, 5])