chainer.functions.hard_sigmoid

chainer.functions.hard_sigmoid(x)[source]

Element-wise hard-sigmoid function.

This function is defined as

f(x)={0if x<2.50.2x+0.5if 2.5<x<2.51if 2.5<x.
Parameters

x (Variable or N-dimensional array) – Input variable. A (s1,s2,...,sN)-shaped float array.

Returns

Output variable. A (s1,s2,...,sN)-shaped float array.

Return type

Variable

Example

It maps the input values into the range of [0,1].

>>> x = np.array([-2.6, -1, 0, 1, 2.6])
>>> x
array([-2.6, -1. ,  0. ,  1. ,  2.6])
>>> F.hard_sigmoid(x).array
array([0. , 0.3, 0.5, 0.7, 1. ])