Hardsigmoid

class paddle.nn. Hardsigmoid ( name=None ) [source]

This interface is used to construct a callable object of the Hardsigmoid class. This layer calcluate the hardsigmoid of input x.

A 3-part piecewise linear approximation of sigmoid(https://arxiv.org/abs/1603.00391), which is much faster than sigmoid.

\[\begin{split}Hardsigmoid(x)= \\left\\{ \\begin{aligned} &0, & & \\text{if } x \\leq -3 \\\\ &1, & & \\text{if } x \\geq 3 \\\\ &x/6 + 1/2, & & \\text{otherwise} \\end{aligned} \\right.\end{split}\]
Parameters

name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Shape:

x: N-D tensor, available dtype is float32, float64.

Returns

A callable object of Hardsigmoid.

Examples

import paddle

m = paddle.nn.Hardsigmoid()
x = paddle.to_tensor([-4., 5., 1.])
out = m(x) # [0., 1, 0.666667]
forward ( x )

forward

Defines the computation performed at every call. Should be overridden by all subclasses.

Parameters
  • *inputs (tuple) – unpacked tuple arguments

  • **kwargs (dict) – unpacked dict arguments

extra_repr ( )

extra_repr

Extra representation of this layer, you can have custom implementation of your own layer.