chainer.functions.relu

chainer.functions.relu(x)[source]

Rectified Linear Unit function.

\[f(x)=\max(0, x).\]
Parameters

x (Variable or N-dimensional array) – 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]], np.float32)
>>> np.any(x < 0)
True
>>> y = F.relu(x)
>>> np.any(y.array < 0)
False
>>> y.shape
(3, 2)