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

22 lines
803 B
ReStructuredText
Raw Normal View History

2022-11-14 21:47:12 +08:00
mindspore.ops.where
====================
.. py:function:: mindspore.ops.where(condition, x, y)
返回一个TensorTensor的元素从 `x``y` 中根据 `condition` 选择。
.. math::
output_i = \begin{cases} x_i,\quad &if\ condition_i \\ y_i,\quad &otherwise \end{cases}
参数:
- **condition** (Union[Bool Tensor, bool, scalar]) - 如果是True选取 `x` 中的元素,否则选取 `y` 中的元素。
- **x** (Union[Tensor, Scalar]) - 在 `condition` 为True的索引处选择的值。
- **y** (Union[Tensor, Scalar]) - 当 `condition` 为False的索引处选择的值。
返回:
Tensor其中的元素从 `x``y` 中选取。
异常:
2022-11-30 15:01:50 +08:00
- **ValueError** - `condition` 不可以被广播成 `x` 的shape。