histogram¶
- paddle. histogram ( input, bins=100, min=0, max=0, name=None ) [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.
- Parameters
-
input (Tensor) – A Tensor(or LoDTensor) with shape \([N_1, N_2,..., N_k]\) . The data type of the input Tensor should be float32, float64, int32, int64.
bins (int, optional) – number of histogram bins. Default: 100.
min (int, optional) – lower end of the range (inclusive). Default: 0.
max (int, optional) – upper end of the range (inclusive). Default: 0.
name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.
- Returns
-
data type is int64, shape is (nbins,).
- Return type
-
Tensor
Examples
>>> import paddle >>> inputs = paddle.to_tensor([1, 2, 1]) >>> result = paddle.histogram(inputs, bins=4, min=0, max=3) >>> print(result) Tensor(shape=[4], dtype=int64, place=Place(cpu), stop_gradient=True, [0, 2, 1, 0])