pytorch中的math operation: torch.bmm()


torch.bmm(batch1batch2out=None) → Tensor

Performs a batch matrix-matrix product of matrices stored in batch1 and batch2.

batch1 and batch2 must be 3-D tensors each containing the same number of matrices.

If batch1 is a (b×n×m)tensor, batch2 is a (b×m×p) tensor, out will be a (b×n×p)tensor.

outi=batch1i@batch2outi=batch1i@batch2i

Note

This function does not broadcast. For broadcasting matrix products, see torch.matmul().

Parameters:
  • batch1 (Tensor) – the first batch of matrices to be multiplied
  • batch2 (Tensor) – the second batch of matrices to be multiplied
  • out (Tensoroptional) – the output tensor

Example:

>>> batch1 = torch.randn(10, 3, 4) >>> batch2 = torch.randn(10, 4, 5) >>> res = torch.bmm(batch1, batch2) >>> res.size() torch.Size([10, 3, 5])


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM