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

22 lines
803 B
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.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` 中选取。
异常:
- **ValueError** - `condition` 不可以被广播成 `x` 的shape。