本文簡要介紹python語言中 torch.clamp
的用法。
用法:
torch.clamp(input, min=None, max=None, *, out=None) → Tensor
out(Tensor,可選的) -輸出張量。
將
input
中的所有元素夾在[
min
、max
]
範圍內。讓 min_value 和 max_value 分別為min
和max
,這將返回:如果
min
是None
,則沒有下限。或者,如果max
是None
,則沒有上限。例子:
>>> a = torch.randn(4) >>> a tensor([-1.7120, 0.1734, -0.0478, -0.0922]) >>> torch.clamp(a, min=-0.5, max=0.5) tensor([-0.5000, 0.1734, -0.0478, -0.0922]) >>> min = torch.linspace(-1, 1, steps=4) >>> torch.clamp(a, min=min) tensor([-1.0000, 0.1734, 0.3333, 1.0000])
參數:
關鍵字參數:
相關用法
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch column_stack用法及代碼示例
- Python PyTorch cumprod用法及代碼示例
- Python PyTorch calculate_gain用法及代碼示例
- Python PyTorch cov用法及代碼示例
- Python PyTorch cos用法及代碼示例
- Python PyTorch compute_deltas用法及代碼示例
- Python PyTorch conv_transpose3d用法及代碼示例
- Python PyTorch combinations用法及代碼示例
- Python PyTorch conv2d用法及代碼示例
- Python PyTorch cummax用法及代碼示例
- Python PyTorch custom_from_mask用法及代碼示例
- Python PyTorch collect_all用法及代碼示例
- Python PyTorch chunk用法及代碼示例
- Python PyTorch convert用法及代碼示例
- Python PyTorch conv1d用法及代碼示例
- Python PyTorch chain_matmul用法及代碼示例
- Python PyTorch cat用法及代碼示例
- Python PyTorch constant_用法及代碼示例
- Python PyTorch context用法及代碼示例
- Python PyTorch count_nonzero用法及代碼示例
- Python PyTorch cdist用法及代碼示例
- Python PyTorch ceil用法及代碼示例
- Python PyTorch cosh用法及代碼示例
- Python PyTorch criteo_terabyte用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.clamp。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。