mindspore.mint.histc

View Source On Gitee
mindspore.mint.histc(input, bins=100, min=0, max=0)[source]

Computes the histogram of a tensor.

The elements are sorted into equal width bins between min and max. If min and max are both zero, the minimum and maximum values of the data are used.

Elements lower than min or higher than max are ignored.

Warning

This is an experimental API that is subject to change or deletion. If input is int64, valid values fit within int32; exceeding this may cause precision errors.

Parameters
  • input (Tensor) – the input tensor.

  • bins (int, optional) – Number of histogram bins, optional. If specified, must be positive. Default: 100 .

  • min (int, float, optional) – the lower end of the range (inclusive), optional. Default: 0 .

  • max (int, float, optional) – the upper end of the range (inclusive), optional. Default: 0 .

Returns

A 1-D Tensor, has the same type as input with the shape \((bins, )\).

Raises
Supported Platforms:

Ascend

Examples

>>> from mindspore import Tensor, mint
>>> x = Tensor([1., 2, 1])
>>> y = mint.histc(x, bins=4, min=0, max=3)
>>> print(y)
[0 2 1 0]