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
and max_val
.
False
Keyword arguments min_value
and max_value
have been deprecated in favor of min_val
and max_val
.
*
means, any number of additional dimensionsExamples:
>>> m = nn.Hardtanh(-2, 2) >>> input = torch.randn(2) >>> output = m(input)
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.7.0/generated/torch.nn.Hardtanh.html