mindspore/docs/api/api_python/numpy/mindspore.numpy.where.rst

20 lines
873 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.numpy.where
=================================
.. py:function:: mindspore.numpy.where(condition, x=None, y=None)
根据 ``condition````x````y`` 中选择元素。
.. note::
由于不支持 ``nonzero`` ``x````y`` 必须都是Tensor输入。
参数:
- **condition** (Tensor) - 当为 ``True`` 时,选择 ``x`` 中的值,否则选择 ``y`` 中的值。
- **x** (Tensor可选) - 选择值的来源。默认值: ``None``
- **y** (Tensor可选) - 选择值的来源。 ``x`` ``y````condition`` 需要能够广播到相同的shape。默认值 ``None``
返回:
Tensor或标量其中 ``condition````True`` 的位置取自 ``x`` ,其他位置取自 ``y``
异常:
- **ValueError** - 如果操作数不能广播到相同的shape。