histogram

paddle. histogram ( input, bins=100, min=0, max=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.

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) – number of histogram bins

  • min (int) – lower end of the range (inclusive)

  • max (int) – upper end of the range (inclusive)

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) # [0, 2, 1, 0]