快捷方式

Hardsigmoid

torch.nn.Hardsigmoid(inplace=False)[源代码][源代码]

逐元素应用 Hardsigmoid 函数。

Hardsigmoid 的定义如下

Hardsigmoid(x)={0如果 x3,1如果 x+3,x/6+1/2否则\text{Hardsigmoid}(x) = \begin{cases} 0 & \text{if~} x \le -3, \\ 1 & \text{if~} x \ge +3, \\ x / 6 + 1 / 2 & \text{otherwise} \end{cases}
参数

inplace (布尔型) – 可以选择是否原地执行操作。默认值: False

形状
  • 输入: ()(*),其中 * 表示任意维度数量。

  • 输出: ()(*),形状与输入相同。

../_images/Hardsigmoid.png

示例

>>> m = nn.Hardsigmoid()
>>> input = torch.randn(2)
>>> output = m(input)

文档

查阅 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源