mindspore2022/docs/api/api_python/ops/mindspore.ops.MatMul.rst

33 lines
1.2 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.matmul
=====================
.. py:class:: mindspore.ops.MatMul(transpose_a=False, transpose_b=False)
将矩阵 `a` 和矩阵 `b` 相乘。
.. math::
(Output)_{i j}=\sum_{k=1}^{p} a_{i k} b_{k j}=a_{i 1} b_{1 j}+a_{i 2} b_{2 j}+\cdots+a_{i p} b_{p j}, p\in N
其中, :math:`i,j` 表示输出的第i行和第j列元素。
**参数:**
- **transpose_a** (bool) - 如果为True则在相乘之前转置 `a`。默认值False。
- **transpose_b** (bool) - 如果为True则在相乘之前转置 `b`。默认值False。
**输入:**
- **a** (Tensor) - 要相乘的第一个Tensor。如果 `transpose_a` 为False则该Tensor的shape为 :math:`(N, C)` 否则该Tensor的shape为 :math:`(C, N)`
- **b** (Tensor) - 要相乘的第二个Tensor。如果 `transpose_b` 为False则该Tensor的shape为 :math:`(C, M)` 否则该Tensor的shape为 :math:`(M, C)`
**输出:**
Tensor输出Tensor的shape为 :math:`(N, M)`
**异常:**
- **TypeError** - `transpose_a``transpose_b` 不是bool。
- **ValueError** - 矩阵 `a` 的列不等于矩阵 `b` 的行。
- **ValueError** - `a``b` 的维度不等于2。