mindspore.Tensor.baddbmm
- Tensor.baddbmm(batch1, batch2, *, beta=1, alpha=1) Tensor
The result is the sum of the self and a batch matrix-matrix product of matrices in batch1 and batch2. The formula is defined as follows:
\[\text{out}_{i} = \beta \text{self}_{i} + \alpha (\text{batch1}_{i} \mathbin{@} \text{batch2}_{i})\]- Parameters
- Keyword Arguments
- Returns
Tensor, has the same dtype as self, shape will be \((C, W, H)\).
- Raises
TypeError – If the type of self, batch1, batch2 is not Tensor.
TypeError – If the types of self, batch1, batch2 are different.
ValueError – If batch1 and batch2 are not 3-D tensors.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> input = Tensor(np.ones([1, 3, 3]).astype(np.float32)) >>> batch1 = Tensor(np.ones([1, 3, 4]).astype(np.float32)) >>> batch2 = Tensor(np.ones([1, 4, 3]).astype(np.float32)) >>> output = input.baddbmm(batch1, batch2) >>> print(output) [[[5. 5. 5.] [5. 5. 5.] [5. 5. 5.]]]