Part 09 / Topic 2 of 6
Activation functions
Without activations, stacked linear layers collapse into one linear layer β W2(W1 x) = (W2 W1) x. The non-linearity between layers is what buys expressive power.
# examples/01_activation_functions_side_by_side.py
z = np.array([-3.0, -1.0, 0.0, 1.0, 3.0])
# ReLU : [0. 0. 0. 1. 3.] keep positives, zero negatives
# sigmoid: [0.047 0.269 0.5 0.731 0.953] squash to (0, 1)
# tanh : [-0.995 -0.762 0. 0.762 0.995] squash to (-1, 1)
ReLU is the modern default for hidden layers: cheap, and its gradient does not vanish for positive inputs. Sigmoid lives on at binary-output layers; tanh in some recurrent cells.
π§ͺ Quick quiz
- Without non-linear activations, a deep network is equivalent toβ¦
Show the answer
A single linear layer β stacking linear maps is still one linear map. The activations are what make depth count.
Done here? The practice set for Part 9 β 4 exercises with solutions β is on the part page.