mindspore.Tensor.any

Tensor.any(axis=(), keep_dims=False)[source]

Check any tensor element along a given axis evaluate to True.

Parameters
  • axis (Union[None, int, tuple(int)]) – Dimensions of reduction. When the axis is None or empty tuple, reduce all dimensions. When the axis is int or tuple(int), if the dimension of Tensor is dim, the value range is [-dim, dim). Default: ().

  • keep_dims (bool) – Whether to keep the reduced dimensions. Default: False.

Returns

Tensor, if any tensor element along the given axis evaluates to True, its value is True, otherwise its value is False. If the axis is None or empty tuple, reduce all dimensions.

Supported Platforms:

Ascend GPU CPU

See also

mindspore.Tensor.all(): Check all tensor elements along a given axis evaluate to True.

Examples

>>> from mindspore import Tensor
>>> a = Tensor([True, True, False])
>>> output = a.any()
>>> print(output)
True