chainer.functions.relu

chainer.functions.relu(x)

Rectified Linear Unit function.

\[f(x)=\max(0, x).\]
Parameters:x (Variable or numpy.ndarray or cupy.ndarray) – Input variable. A \((s_1, s_2, ..., s_N)\)-shaped float array.
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')
>>> np.any(x < 0)
True
>>> y = F.relu(x)
>>> np.any(y.data < 0)
False
>>> y.shape
(3, 2)