mindspore/docs/api/api_python/ops/mindspore.ops.Select.rst

27 lines
1023 B
ReStructuredText
Raw Permalink Normal View History

2022-05-16 10:54:10 +08:00
mindspore.ops.Select
=========================
.. py:class:: mindspore.ops.Select
2022-05-19 11:31:30 +08:00
根据条件判断Tensor中的元素的值决定输出中的相应元素是从 `x` 如果元素值为True还是从 `y` 如果元素值为False中选择。
2022-05-16 10:54:10 +08:00
该算法可以被定义为:
.. math::
out_i = \begin{cases}
x_i, & \text{if } condition_i \\
y_i, & \text{otherwise}
\end{cases}
2022-07-22 11:20:32 +08:00
输入:
- **condition** (Tensor[bool]) - 条件Tensor决定选择哪一个元素shape是 :math:`(x_1, x_2, ..., x_N, ..., x_R)`
- **x** (Tensor) - 第一个被选择的Tensorshape是 :math:`(x_1, x_2, ..., x_N, ..., x_R)`
- **y** (Tensor) - 第二个被选择的Tensorshape是 :math:`(x_1, x_2, ..., x_N, ..., x_R)`
2022-05-16 10:54:10 +08:00
2022-07-22 11:20:32 +08:00
输出:
2022-10-24 00:38:10 +08:00
Tensor具有与输入 `condition` 相同的shape。
2022-05-16 10:54:10 +08:00
2022-07-22 11:20:32 +08:00
异常:
- **TypeError** - 如果 `x` 或者 `y` 不是Tensor。
2022-11-02 19:28:41 +08:00
- **ValueError** - 如果三个输入的shape不一致。