本文簡要介紹python語言中 torch.aminmax
的用法。
用法:
torch.aminmax(input, *, dim=None, keepdim=False, out=None) ->(Tensor min, Tensor max)
input(Tensor) -輸入張量
dim(可選的[int]) -沿其計算值的維度。如果
None
,計算整個input
張量的值。默認為None
。keepdim(bool) -如果是
True
,則減少的維度將作為大小為 1 的維度保留在輸出張量中以用於廣播,否則它們將被刪除,就像調用 (torch.squeeze()
)。默認為False
。out(可選的[元組[Tensor,Tensor]]) - 用於寫入結果的可選張量。必須具有與預期輸出相同的形狀和數據類型。默認為
None
.
包含最小值和最大值的命名元組
(min, max)
。RuntimeError - 如果要計算值的任何維度的大小為 0。
計算
input
張量的最小值和最大值。注意
如果至少有一個值為 NaN,則 NaN 值將傳播到輸出。
例子:
>>> torch.aminmax(torch.tensor([1, -3, 5])) torch.return_types.aminmax( min=tensor(-3), max=tensor(5)) >>> # aminmax propagates NaNs >>> torch.aminmax(torch.tensor([1, -3, 5, torch.nan])) torch.return_types.aminmax( min=tensor(nan), max=tensor(nan)) >>> t = torch.arange(10).view(2, 5) >>> t tensor([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) >>> t.aminmax(dim=0, keepdim=True) torch.return_types.aminmax( min=tensor([[0, 1, 2, 3, 4]]), max=tensor([[5, 6, 7, 8, 9]]))
參數:
關鍵字參數:
返回:
拋出:
相關用法
- Python PyTorch amin用法及代碼示例
- Python PyTorch amax用法及代碼示例
- Python PyTorch argsort用法及代碼示例
- Python PyTorch addmm用法及代碼示例
- Python PyTorch addmv用法及代碼示例
- Python PyTorch apply_effects_tensor用法及代碼示例
- Python PyTorch assert_close用法及代碼示例
- Python PyTorch angle用法及代碼示例
- Python PyTorch all_reduce用法及代碼示例
- Python PyTorch atanh用法及代碼示例
- Python PyTorch annotate用法及代碼示例
- Python PyTorch async_execution用法及代碼示例
- Python PyTorch argmax用法及代碼示例
- Python PyTorch atan用法及代碼示例
- Python PyTorch as_strided用法及代碼示例
- Python PyTorch acos用法及代碼示例
- Python PyTorch all_gather用法及代碼示例
- Python PyTorch avg_pool1d用法及代碼示例
- Python PyTorch asin用法及代碼示例
- Python PyTorch allreduce_hook用法及代碼示例
- Python PyTorch argmin用法及代碼示例
- Python PyTorch any用法及代碼示例
- Python PyTorch all_to_all用法及代碼示例
- Python PyTorch asinh用法及代碼示例
- Python PyTorch add用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.aminmax。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。