mindspore.Tensor.histc
- Tensor.histc(bins=100, min=0, max=0) Tensor
Computes the histogram of self.
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 self are used.
Elements below the minimum value and above the maximum value are ignored.
Warning
If self is int64, valid values fit within int32; exceeding this may cause precision errors.
- Parameters
- Returns
A 1-D Tensor, has the same type as self with the shape \((bins, )\).
- Raises
TypeError – If self is not a Tensor.
TypeError – If attr min or max is not float or int.
TypeError – If attr bins is not int.
ValueError – If attr value min > max.
ValueError – If attr bins <= 0.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor >>> input = Tensor(np.array([1., 2., 1.]), mindspore.float32) >>> output = input.histc(bins=4, min=0, max=3) >>> print(y) [0. 2. 1. 0.]