chainer.functions.rrelu(x, l=1.0 / 8, u=1.0 / 3, *, r=None, return_r=False)[source]

Randomized Leaky Rectified Liner Unit function.

This function is expressed as

\[f(x)=\max(x, rx),\]

where \(r\) is a random number sampled from a uniform distribution \(U(l, u)\).


The \(r\) corresponds to \(a\) in the original paper (

  • x (Variable or N-dimensional array) – Input variable. A \((s_1, s_2, ..., s_N)\)-shaped float array.

  • l (float) – The lower bound of the uniform distribution.

  • u (float) – The upper bound of the uniform distribution.

  • r (N-dimensional array or None) – The r to be used for rrelu. The shape and dtype must be the same as x[0] and should be on the same device. If r is not specified or set to None, an r will be generated randomly according to the given l and u. If r is specified, l and u will be ignored.

  • return_r (bool) – If True, the r used for rrelu is returned altogether with the output variable. The returned r can latter be reused by passing it to r argument.


When return_r is False (default), return the output variable. Otherwise returnes the tuple of the output variable and r (N-dimensional array). The r will be on the same device as the input. A \((s_1, s_2, ..., s_N)\)-shaped float array.

Return type

Variable or tuple


>>> x = np.array([[-1, 0], [2, -3], [-2, 1]], np.float32)
>>> x
array([[-1.,  0.],
       [ 2., -3.],
       [-2.,  1.]], dtype=float32)
>>> F.rrelu(x).array 
array([[-0.24850948,  0.        ],
       [ 2.        , -0.50844127],
       [-0.598535  ,  1.        ]], dtype=float32)