mindspore.ops.histc
- mindspore.ops.histc(input, bins=100, min=0.0, max=0.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.
- Parameters
input (Tensor) – the input tensor, type support list \([float16, float32, int32]\).
bins (int, optional) – Number of histogram bins, optional. If specified, must be positive. Default:
100
.min (int, float, optional) – An optional float of the lower end of the range (inclusive). Default value is 0.0.
max (int, float, optional) – An optional float of the upper end of the range (inclusive). Default value is 0.0.
- Returns
Tensor, 1-D Tensor with type int32.
- Raises
TypeError – If input is not a Tensor.
TypeError – If input datetype not in support list.
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
CPU
Examples
>>> x = Tensor([1., 2, 1]) >>> y = ops.histc(x, bins=4, min=0.0, max=3.0) >>> print(y) [0 2 1 0]