Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.bmm function

PyTorch torch.bmm function


PyTorch torch reference manual 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

)

print

(

"Batched result shape:"

,

result.

shape

)

The output is:

批量结果形状: torch.Size([10, 3, 5])


PyTorch torch reference manual PyTorch torch reference manual