當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python PyTorch histc用法及代碼示例

本文簡要介紹python語言中 torch.histc 的用法。

用法:

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

參數

  • input(Tensor) -輸入張量。

  • bins(int) -直方圖箱數

  • min(int) -範圍的下限(包括)

  • max(int) -範圍的上限(包括)

關鍵字參數

out(Tensor,可選的) -輸出張量。

返回

直方圖表示為張量

返回類型

Tensor

計算張量的直方圖。

元素被分類到 min max 之間等寬的 bin 中。如果 min max 都為零,則使用數據的最小值和最大值。

低於 min 和高於 max 的元素將被忽略。

例子:

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

相關用法


注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.histc。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。