mindspore.mint.any

查看源文件
mindspore.mint.any(input, dim=None, keepdim=False)[源代码]

检查指定维度上是否含有 True

参数:
  • input (Tensor) - 输入tensor。

  • dim (Union[int, tuple(int), list(int), Tensor], 可选) - 要减少的维度。如果为 None,减少所有维度。默认 None

  • keepdim (bool, 可选) - 输出tensor是否保留维度。默认 False

返回:

Tensor

支持平台:

Ascend

样例:

>>> import mindspore
>>> input = mindspore.tensor([[True, False], [True, True]])
>>>
>>> # case 1:  By default, mindspore.mint.any tests along all the axes.
>>> mindspore.mint.any(input)
Tensor(shape=[], dtype=Bool, value= True)
>>>
>>> # case 2: Reduces a dimension along dim 1, with keepdim False.
>>> mindspore.mint.any(input, dim=1)
Tensor(shape=[2], dtype=Bool, value= [ True,  True])
>>>
>>> # case 3: Reduces a dimension along dim (0, 1), with keepdim False.
>>> mindspore.mint.any(input, dim=(0,1))
Tensor(shape=[], dtype=Bool, value= True)
>>>
>>> # case 4: Reduces a dimension along dim [0, 1], with keepdim True.
>>> mindspore.mint.any(input, dim=[0,1], keepdim=True)
Tensor(shape=[1, 1], dtype=Bool, value=
[[ True]])