mindspore/docs/api/api_python/nn/mindspore.nn.MatrixSetDiag.rst

32 lines
1.3 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.nn.MatrixSetDiag
===========================
.. py:class:: mindspore.nn.MatrixSetDiag
将输入的对角矩阵的对角线值置换为输入的对角线值。
假设 `x`:math:`k+1` 个维度 :math:`[I,J,K,...,M,N]` `diagonal`:math:`k` 个维度 :math:`[I, J, K, ..., min(M, N)]` ,则输出秩为 :math:`k+1` ,维度为 :math:`[I, J, K, ..., M, N]` 的Tensor其中
.. math::
output[i, j, k, ..., m, n] = diagnoal[i, j, k, ..., n]\ for\ m == n
.. math::
output[i, j, k, ..., m, n] = x[i, j, k, ..., m, n]\ for\ m != n
**输入:**
- **x** (Tensor) - 输入的对角矩阵。秩为k+1k大于等于1。支持如下数据类型float32、float16、int32、int8和uint8。
- **diagonal** (Tensor) - 输入的对角线值。必须与输入 `x` 的shape相同。秩为kk大于等于1。
**输出:**
Tensorshape和数据类型与输入 `x` 相同。
**异常:**
- **TypeError** - `x``diagonal` 的数据类型不是float32、float16、int32、int8或uint8。
- **ValueError** - `x` 的shape长度小于2。
- **ValueError** - :math:`x\_shape[-2] < x\_shape[-1]`:math:`x\_shape[:-1] != diagonal\_shape`
- **ValueError** - :math:`x\_shape[-2] >= x\_shape[-1]`:math:`x\_shape[:-2] + x\_shape[-1:] != diagonal\_shape`