ReLU is a simple nonlinear activation that helps feed-forward and convolutional networks converge to more accurate solutions in fewer epochs than saturating activations such as tanh or sigmoid. section 6.1.2 section 6.0
For an input x, ReLU(x) = max(0, x): positive inputs pass through unchanged, while negative inputs become zero. Its derivative is 1 for positive inputs and 0 for nonpositive inputs. section 6.1.2
Use ReLU with these tradeoffs in mind:
- Prefer it when saturated tanh or sigmoid activations cause vanishing-gradient concerns; its positive region keeps a constant derivative. section 6.1.2
- Watch for inactive neurons: inputs at or below zero receive no gradient, which can be damaging in very small networks. section 6.1.2
- Consider LeakyReLU when a nonzero negative-side gradient is useful; it replaces the hard zero with a small slope. section 6.1.2 section 6.1.3
Compare the activation shapes
Generate inputs from -5 to 5 and compute `relu_activation = np.maximum(0, activation_input)`. Plot it alongside tanh, sigmoid, and LeakyReLU to see ReLU’s zero-valued negative region and linear positive region. section 6.1.2
activation_input = np.linspace(-5, 5, num=200) relu_activation =
np.maximum(0,activation_input) leaky_relu_activation =
np.maximum(0.3*activation_input,activation_input)
sns.lineplot(x=activation_input, y=tanh_activation, color=’red’,
label="tanh(x)")
sns.lineplot(x=activation_input, y=sigmoid_activation, color=’blue’,
label="σ(x)")
sns.lineplot(x=activation_input, y=relu_activation, color=’green’,
label="ReLU(x)")
sns.lineplot(x=activation_input, y=leaky_relu_activation, color=’purple’,
label="LeakyReLU(x)")
[15]: <AxesSubplot:>
Inspect the supplied activation-function comparison, including ReLU and LeakyReLU values across negative and positive inputs. section 6.1.2











