Softmax
Dog Cat Watermelon toy
0.6 0.2 0.05 0.15
Derivative of softmax
Goal:
A derivative of a quotient:
First, assume i = j
Now, assume i ≠ j
In summary:
Gradient descent for multiclass logistic regression
Logistic regression: gradient calculation
We have one example (xi, yi) and calculate gradient with respect to row k in W
Logistic regression: gradient calculation
Beyond linear classifiers
Reminder: Chain Rule
Visualization
Backpropagation
We will calculate parameter updates for the following MLP model:
Backpropagation
We start by calculating ∂l/∂W2. This is easy! Just ignore the rest of the network.
We will use the chain rule to calculate the gradient ∂l/∂W1. We will start by calculating ∂l/∂h1
Now that we have ∂l/∂h1, we will continue by calculating ∂h1[p]/∂zi[j]. What is the dimensionality of the gradient ∂h1/∂z?
Now that we have both ∂l/∂h1[p] and ∂h1[p]/∂zi[j] we can calculate ∂l/∂z1[j] with the chain rule:
With ∂l/∂z1[j] we can finally calculate ∂l/∂w1[j] (!!!)
Completely analogous to the formula for ∂l/∂w2[j] !
What if we had another layer before xt?
Conclusions
*
Backpropagation Algorithm for multiclass MLP
In practice: automatic differentiation
The computation graph
In practice: computation graphs
Forward pass
Backward pass