Hardtanh¶
- class torch.nn.Hardtanh(min_val=-1.0, max_val=1.0, inplace=False, min_value=None, max_value=None)[source][source]¶
逐元素应用 HardTanh 函数。
HardTanh 定义为
- 参数
关键字参数
min_value
和max_value
已弃用,推荐使用min_val
和max_val
。- 形状
输入: ,其中 表示任意数量的维度。
输出: ,与输入相同的形状。
示例
>>> m = nn.Hardtanh(-2, 2) >>> input = torch.randn(2) >>> output = m(input)