Deep Learning · TEE · section
Derivatives: from an ordinary change to a local slope
The maths behind a network
1. Function value and change are different numbers
Let L(w) = w². At w = 3, loss is 9. If we increase w to 4, loss becomes 16. The loss change is 16 − 9 = 7 and the weight change is 4 − 3 = 1. Their ratio is 7. This is an average slope over a whole interval.
\text{average slope}=\frac{\text{new loss}-\text{old loss}}{\text{new weight}-\text{old weight}}2. Shrink the interval
For the same starting weight 3, use an increase of 0.1. The new weight is 3.1 and its square is 9.61. The slope estimate is (9.61 − 9)/0.1 = 6.1. With an increase of 0.01, it is (9.0601 − 9)/0.01 = 6.01. Smaller intervals approach 6.
| Increase in w | New w | New loss w² | Change in loss | Change ratio |
|---|---|---|---|---|
| 1 | 4 | 16 | 7 | 7 |
| 0.1 | 3.1 | 9.61 | 0.61 | 6.1 |
| 0.01 | 3.01 | 9.0601 | 0.0601 | 6.01 |
The derivative is the limiting local slope as that interval approaches zero. We do not substitute a literal zero into a division by the interval.
3. Why the square has derivative 2w
Call a small nonzero change Δw, read “delta w”. Expanding the new square gives:
(w+\Delta w)^2=w^2+2w\Delta w+(\Delta w)^2Subtract the old square w² and divide by the change Δw:
\frac{(w+\Delta w)^2-w^2}{\Delta w}=2w+\Delta wAs Δw approaches zero, this approaches 2w. That is the origin of the rule d(w²)/dw = 2w. At w = 3 it gives 6, matching the table's trend.
4. Reading derivative notation
In dL/dw, the top names the quantity whose response we study, and the bottom names what we vary. Read it as “the derivative of L with respect to w”. The notation is not asking you to divide the current loss 9 by the current weight 3; that would give 3 and answer a different question.
For a function of several variables, ∂L/∂w is a partial derivative: change w while holding the other independent variables fixed. The gradient groups those partial derivatives for all parameters.
5. Why subtract the gradient?
If the derivative is positive, increasing w locally increases loss, so we try a small decrease. If it is negative, increasing w locally decreases loss, so we try a small increase. The subtraction in gradient descent automatically handles both signs.
w_{\mathrm{new}}=w-\eta gThis is local information. A very large step can cross a minimum and make loss worse. The learning rate η keeps control of the step; the derivative does not promise that any step size is safe.