mindspore.mint.histc

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

Compute 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

If input is mindspore.int64, valid values fit within mindspore.int32; exceeding this may cause precision errors.

Parameters
  • input (Tensor) – The input tensor.

  • bins (int, optional) – Number of histogram bins. Default 100.

  • min (int, float, optional) – Minimum value of the histogram data range. Default 0.

  • max (int, float, optional) – Maximum value of the histogram data range. Default 0.

Returns

Tensor

Supported Platforms:

Ascend

Examples

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