Hardsigmoid

class torch.nn.Hardsigmoid(inplace=False) [source]

Applies the element-wise function:

Hardsigmoid(x)={0if x3,1if x+3,x/6+1/2otherwise\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}
Parameters

inplace – can optionally do the operation in-place. Default: False

Shape:
  • Input: (N,)(N, *) where * means, any number of additional dimensions
  • Output: (N,)(N, *) , same shape as the input

Examples:

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

© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.nn.Hardsigmoid.html