Hardsigmoid

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

Apply the hard sigmoid function.

The HardSigmoid function is defined as:

\[\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} \]

Examples:

m = torch.nn.Hardsigmoid()
x = torch.randn(2, 3)
y = m(x)

__init__

Hardsigmoid.__init__(inplace=False)[source]

Create a Hardsigmoid module.

Parameters:
  • inplace (bool, optional, default=False) – Whether to do the operation in-place.