mindspore.Tensor.masked_select

查看源文件
mindspore.Tensor.masked_select(mask)

详情请参考 mindspore.ops.masked_select()

支持平台:

Ascend GPU CPU

样例:

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([1, 2, 3, 4]), mindspore.int64)
>>> mask = Tensor(np.array([1, 0, 1, 0]), mindspore.bool_)
>>> output = x.masked_select(mask)
>>> print(output)
[1 3]