本文簡要介紹python語言中 torch.nn.Hardtanh
的用法。
用法:
class torch.nn.Hardtanh(min_val=- 1.0, max_val=1.0, inplace=False, min_value=None, max_value=None)
min_val-線性區域範圍的最小值。默認值:-1
max_val-線性區域範圍的最大值。默認值:1
inplace-可以選擇就地執行操作。默認值:
False
按元素應用HardTanh 函數
HardTanh 定義為:
可以使用
min_val
和max_val
調整線性區域 的範圍。關鍵字參數
min_value
和max_value
已被棄用,取而代之的是min_val
和max_val
。- 形狀:
輸入: ,其中 表示任意數量的維度。
輸出: ,與輸入的形狀相同。
例子:
>>> m = nn.Hardtanh(-2, 2) >>> input = torch.randn(2) >>> output = m(input)
參數:
相關用法
- Python PyTorch Hardsigmoid用法及代碼示例
- Python PyTorch Hardshrink用法及代碼示例
- Python PyTorch Hardswish用法及代碼示例
- Python PyTorch HalfCauchy用法及代碼示例
- Python PyTorch HalfNormal用法及代碼示例
- Python PyTorch HashChecker用法及代碼示例
- Python PyTorch HashStore用法及代碼示例
- Python PyTorch Header用法及代碼示例
- Python PyTorch HttpReader用法及代碼示例
- 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用法及代碼示例
- Python PyTorch Tensor.unflatten用法及代碼示例
- Python PyTorch Sigmoid用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.nn.Hardtanh。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。