mindspore.ops.HistogramFixedWidth
- class mindspore.ops.HistogramFixedWidth(nbins, dtype='int32')[source]
Returns a rank 1 histogram counting the number of entries in values that fall into every bin. The bins are equal width and determined by the inputs range and the arguments nbins.
- Parameters
- Inputs:
x (Tensor) - Numeric Tensor. Must be one of the following types: int32, float32, float16.
range (Tensor) - Must have the same data type as x, and the shape is \((2,)\). x <= range[0] will be mapped to histogram[0], x >= range[1] will be mapped to histogram[-1].
- Outputs:
1-D Tensor, whose length is the type is nbins with dtype of int32.
- Raises
TypeError – If dtype is not a str or nbins is not an int.
ValueError – If nbins is less than 1.
ValueError – If dtype is not ‘int32’.
- Supported Platforms:
Ascend
GPU
Examples
>>> x = Tensor([-1.0, 0.0, 1.5, 2.0, 5.0, 15], mindspore.float16) >>> range_op = Tensor([0.0, 5.0], mindspore.float16) >>> hist = ops.HistogramFixedWidth(5) >>> output = hist(x, range_op) >>> print(output) [2 1 1 0 2]