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

21 lines
721 B
ReStructuredText
Raw Permalink 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, input, other)
返回一个tensor其中元素根据 `condition``input``other` 中选择。
支持广播。
.. math::
output_i = \begin{cases} input_i,\quad &if\ condition_i \\ other_i,\quad &otherwise \end{cases}
参数:
- **condition** (Tensor[bool]) - 如果为 ``True`` ,选取 `input` 中的元素,否则选取 `other` 中的元素。
- **input** (Union[Tensor, Scalar]) - 在 `condition```True`` 的索引处选择的值。
- **other** (Union[Tensor, Scalar]) - 当 `condition```False`` 的索引处选择的值。
返回:
Tensor