๐ค What you need to know before reading paper?
This section is essential if you want a quick refresher or need to learn the basics of deep learning.
โIf I have seen further, it is by standing on the shoulders of giants.โ โ Sir Isaac Newton
Isaac Newton famously said he only saw further by standing on the shoulders of giants. Before we look at where the authors are taking us, we need to take a quick look at the โgiantsโ they are standing onโthe basic background of this field.
Lets start..Gradient descent?
Training of DNN(deep neural networks) is a problem of minimizing a function f : Rโฟ โ R
๐ค f : Rโฟ โ R means: you feed f a vector of n real numbers, and it spits out one real number.
Examples:
- n = 2: f : Rยฒ โ R takes a pair (x, y) and returns one number.
This is like a surface โ for every point (x, y) on a plane, you get a height. Think of a hill: input is your (latitude, longitude)-style location, output is the elevation there.
โTo optimize f we iteratively adjust xโ โ โโฟ (the parameter vector at time step t) using gradient information โfโ(xโ).โ
This process is almost always written as:
\[x_{t+1} = x_t - \eta \, \nabla f_t(x_t)\]- xโโโ โ the new parameter vector (next step)
- xโ โ current parameter vector
- ฮท (eta) โ the learning rate / step size (how big a step to take)
- โfโ(xโ) โ the gradient at the current point
- The minus sign means: move against the gradient, i.e., downhill
๐ค But, Where is the data points from train set lives?
f (or fโ) is not just a function of x โ itโs secretly a function of both the parameters and the data. The full picture is usually:
z_i = (input_i, label_i)โ a single data point (e.g., an image and its class)Bโโ the batch of data points sampled at time stept(could be one example, a mini-batch, or the whole dataset)โ(x; z_i)โ the loss on a single example, given parametersxfโ(x)โ the average loss over the batch, at parametersx
So fโ(xโ) = โplug the current parameters xโ into the model, run them against batch Bโ, and compute the average loss.โ
Also good to know that gradient of a loss function is a function itself
There is also second order methods, instead of just using GD
Second-order methods use curvature to correct the step:
\[x_{t+1} = x_t - \eta_t H_t^{-1} \nabla f_t(x_t)\]๐ค what is H?
The Hessian is the matrix of second derivatives of f โ it tells you about the curvature of the loss surface, not just its slope.
From Gradient to Hessian
The Hessian is the matrix of second derivatives of f โ it tells you about the curvature of the loss surface, not just its slope.
-
Gradient
โf(x)โ a vector of first derivatives (โf/โxโ, โf/โxโ, โฆ, โf/โxโ). Tells you the slope in each direction โ which way is downhill. -
Hessian
Hโ a matrix of second derivatives. Tells you how the slope itself is changing โ i.e., whether the surface is curving like a bowl, a saddle, a ridge, etc.
๐ค Why Itโs a Problem in Practice
For a model with n parameters:
Gradient โf - n numbers - cheap
Hessian H - n ร n numbers - expensive to compute
Inverse Hessian Hโปยน - n ร n - very expensive to compute (roughly O(nยณ))
๐ค you will probably ask a question, why we say that Hessian is a maxtrix
if f(x) = xยณ (single variable, n = 1):
f'(x) = 3xยฒ(gradient โ 1 number, since n=1)f''(x) = 6x(Hessian โ which is justโฆ a number)
ANSWER
So when n = 1, the โmatrixโ has exactly one entry, and it collapses down to what you already know as the ordinary second derivative. Nothing new happens โ this is the degenerate case.
๐ค Where It Actually Becomes a Matrix
The Hessian only becomes a real matrix (more than 1 entry) when you have more than one variable โ because now you need to ask not just โhow does the slope change,โ but โhow does the slope in each direction change as I move in each directionโ โ and there are multiple combinations of that.
SGD with momentum
Instead of stepping purely based on the current gradient, you keep a โmemoryโ of past gradients that keeps pushing you in a consistent direction.
The Two Equations
update the velocity:
\[v_{t+1} = \mu_t v_t - \eta_t \nabla f_t(x_t)\]update the parameters using velocity:
\[x_{t+1} = x_t + v_{t+1}\]Compare this to plain gradient descent, which you already know:
\[x_{t+1} = x_t - \eta_t \nabla f_t(x_t)\]The difference: plain GD moves you directly by the (scaled) gradient. Momentum instead updates a separate velocity vector v, and that is what moves you.