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

24 lines
757 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.select
====================
.. py:function:: mindspore.ops.select(condition, input, other)
根据条件判断tensor中的元素的值来决定输出中的相应元素是从 `input` 如果元素值为True还是从 `other` 如果元素值为False中选择。
该算法可以被定义为:
.. math::
out_i = \begin{cases}
input_i, & \text{if } condition_i \\
other_i, & \text{otherwise}
\end{cases}
参数:
- **condition** (Tensor[bool]) - 条件tensor。
- **input** (Union[Tensor, int, float]) - 第一个被选择的tensor或数字。
- **other** (Union[Tensor, int, float]) - 第二个被选择的tensor或数字。
返回:
Tensor