torch / nn / torch.nn
Hardtanh¶
-
class
torch.nn.
Hardtanh
(min_val: float = -1.0, max_val: float = 1.0, inplace: bool = False, min_value: Optional[float] = None, max_value: Optional[float] = None)[source]¶ Applies the HardTanh function element-wise
HardTanh is defined as:
The range of the linear region can be adjusted using
min_val
andmax_val
.- Parameters
min_val – minimum value of the linear region range. Default: -1
max_val – maximum value of the linear region range. Default: 1
inplace – can optionally do the operation in-place. Default:
False
Keyword arguments
min_value
andmax_value
have been deprecated in favor ofmin_val
andmax_val
.- Shape:
Input: where * means, any number of additional dimensions
Output: , same shape as the input
Examples:
>>> m = nn.Hardtanh(-2, 2) >>> input = torch.randn(2) >>> output = m(input)
此页内容是否对您有帮助