chainer.functions.leaky_relu

chainer.functions.leaky_relu(x, slope=0.2)[source]

Leaky Rectified Linear Unit function.

This function is expressed as

\[\begin{split}f(x) = \left \{ \begin{array}{ll} x & {\rm if}~ x \ge 0 \\ ax & {\rm if}~ x < 0, \end{array} \right.\end{split}\]

where \(a\) is a configurable slope value.

Parameters:
Returns:

Output variable. A \((s_1, s_2, ..., s_N)\)-shaped float array.

Return type:

Variable

Example

>>> x = np.array([[-1, 0], [2, -3], [-2, 1]], 'f')
>>> x
array([[-1.,  0.],
       [ 2., -3.],
       [-2.,  1.]], dtype=float32)
>>> F.leaky_relu(x, slope=0.2).data
array([[-0.2       ,  0.        ],
       [ 2.        , -0.60000002],
       [-0.40000001,  1.        ]], dtype=float32)