本文簡要介紹python語言中 torch.histogram
的用法。
用法:
torch.histogram(input, bins, *, range=None, weight=None, density=False, out=None)
input(Tensor) -輸入張量。
bins-int 或一維張量。如果是 int,則定義equal-width bin 的數量。如果是張量,則定義 bin 邊的序列,包括最右邊的邊。
包含直方圖值的一維張量。 bin_edges(Tensor):包含直方圖箱邊的一維張量。
曆史(Tensor)
計算張量中值的直方圖。
bins
可以是整數或一維張量。如果
bins
是一個int,它指定equal-width bins 的數量。默認情況下,bin 的下限和上限範圍由輸入張量的最小和最大元素確定。可以提供range
參數來指定 bin 的範圍。如果
bins
是一維張量,它指定 bin 邊的序列,包括最右邊的邊。它應至少包含 2 個元素,並且其元素應不斷增加。例子:
>>> torch.histogram(torch.tensor([1., 2, 1]), bins=4, range=(0., 3.), weight=torch.tensor([1., 2., 4.])) (tensor([ 0., 5., 2., 0.]), tensor([0., 0.75, 1.5, 2.25, 3.])) >>> torch.histogram(torch.tensor([1., 2, 1]), bins=4, range=(0., 3.), weight=torch.tensor([1., 2., 4.]), density=True) (tensor([ 0., 0.9524, 0.3810, 0.]), tensor([0., 0.75, 1.5, 2.25, 3.]))
參數:
關鍵字參數:
返回:
返回類型:
相關用法
- Python PyTorch histc用法及代碼示例
- Python PyTorch help用法及代碼示例
- Python PyTorch hessian用法及代碼示例
- Python PyTorch hsplit用法及代碼示例
- Python PyTorch hfft用法及代碼示例
- Python PyTorch hstack用法及代碼示例
- Python PyTorch hypot用法及代碼示例
- Python PyTorch heaviside用法及代碼示例
- Python PyTorch householder_product用法及代碼示例
- Python PyTorch handle_torch_function用法及代碼示例
- Python PyTorch hvp用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
- Python PyTorch positive用法及代碼示例
- Python PyTorch renorm用法及代碼示例
- Python PyTorch AvgPool2d用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch Bernoulli用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.histogram。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。