mlx.core.count_nonzero

mlx.core.count_nonzero#

count_nonzero(a: array, /, *, axis: None | int | Sequence[int] = None, keepdims: bool = False, stream: StreamOrDevice = None) → array#

Count the number of non-zero elements along the given axis.

參數:
  • a (array) -- 輸入陣列。

  • axis (int or tuple(int), optional) -- Axis or axes to count over. Defaults to None in which case the whole array is counted.

  • keepdims (bool, optional) -- Keep the reduced axes as size one. Default: False.

回傳值:

The counts as an int32 array.

回傳值型別:

array