Shortcuts

torch.histc

torch.histc(input, bins=100, min=0, max=0, *, out=None) 张量

计算张量的直方图。

元素被排序到在 minmax 之间的等宽区间中。如果 minmax 都为零,则使用数据的 最小值和最大值。

低于最小值和高于最大值以及NaN的元素将被忽略。

Parameters
  • 输入 (张量) – 输入张量。

  • bins (int) – 直方图的箱数

  • 最小值 (标量) – 范围的下限(包含)

  • 最大值 (标量) – 范围的上限(包含)

Keyword Arguments

输出 (张量, 可选) – 输出张量。

Returns

直方图表示为张量

Return type

张量

示例:

>>> torch.histc(torch.tensor([1., 2, 1]), bins=4, min=0, max=3)
tensor([ 0.,  2.,  1.,  0.])