mindspore.Tensor.addmm
- Tensor.addmm(mat1, mat2, *, beta=1, alpha=1) Tensor
Performs a matrix multiplication of the 2-D matrices mat1 and mat2. The matrix self is added to the final result. The formula is defined as follows:
\[output = \beta self + \alpha (mat1 @ mat2)\]Warning
This is an experimental API that is subject to change or deletion.
- Parameters
- Keyword Arguments
- Returns
Tensor, with the same dtype as self and the same shape as mat1 @ mat2.
- Raises
TypeError – If the type of self, mat1 or mat2 is not Tensor.
TypeError – If the types of self, mat1, mat2 are different.
ValueError – If mat1 and mat2 are not 2-D tensors.
- Supported Platforms:
Ascend
Examples
>>> import numpy as np >>> from mindspore import Tensor, mint >>> input = Tensor(np.ones([3, 3]).astype(np.float32)) >>> mat1 = Tensor(np.ones([3, 4]).astype(np.float32)) >>> mat2 = Tensor(np.ones([4, 3]).astype(np.float32)) >>> output = input.(mat1, mat2) >>> print(output) [[5. 5. 5.] [5. 5. 5.] [5. 5. 5.]]