mindspore.ops.any
- mindspore.ops.any(input, axis=None, keep_dims=False)[source]
Tests if any element in input evaluates to True along the given axes.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> input = mindspore.tensor([[True, False], [True, True]]) >>> >>> # case 1: By default, mindspore.ops.any tests along all the axes. >>> mindspore.ops.any(input) Tensor(shape=[], dtype=Bool, value= True) >>> >>> # case 2: Reduces a dimension along axis 2, with keep_dims False. >>> mindspore.ops.any(input, axis=1) Tensor(shape=[2], dtype=Bool, value= [ True, True]) >>> >>> # case 3: Reduces a dimension along axis (2, 3), with keep_dims False. >>> mindspore.ops.any(input, axis=(0,1)) Tensor(shape=[], dtype=Bool, value= True) >>> >>> # case 4: Reduces a dimension along axis [2, 3], with keep_dims True. >>> mindspore.ops.any(input, axis=[0,1], keep_dims=True) Tensor(shape=[1, 1], dtype=Bool, value= [[ True]])