34 min total

Deep Learning

Optimization algorithms

Optimization algorithms

Mini-batch gradient descent

Optimization algorithms — diagram

If there are 5M training examples, it is very costly to update weights after iterating every training example

5,000 mini-batches of 1,000 each

Epoch = single pass through the training set

Optimization algorithms — diagram
Mini batch sizeTerm
1Stochastic gradient descent
1<t<mMini-batch gradient descent
mBatch gradient descent

For training sets <2000 use batch gradient descent

Due to computer memory sizes, mini batches of size works really well

Exponentially weighted averages

Optimization algorithms — diagram

If B = 0.9

Here vₜ is the exponentially weighted average of temperature.

If B = 0.98

If B = 0.5

We are smoothing the curve

We can decide who to give more weight to,

previous calculated value or current input value

Bias correction

Optimization algorithms — diagram

We want to make sure that purple line doesn’t starts from 0

We do these calculations to ensure that purple line is altered into green line

Optimization geometry

Optimization algorithms — diagram

These lines are called contour lines (level curves) of cost function

Each contour Line represent that cost function has the same value

Innermost circle represents minimum value of cost function

Gradient descent with momentum

Optimization algorithms — diagram

β is the momentum hyperparameter.

B = 0.9 (preferred)

Momentum averages out the oscillations

Consider the analogy of ball moving rolling down the hill and we provide it

Friction, velocity and acceleration

RMSprop

We had to decrease the learning in vertical direction and speed up learning in horizontal direction in order for faster convergence

Optimization algorithms — diagram

In directions where the gradients are smaller, such as horizontal direction with smaller dW, the change remains higher

In directions where the gradients are higher (oscillations), such as vertical direction in this example with higher db, the change remains slower

Adam optimization algorithm

Adaptive moment estimation

Combines exponential weighted average and RMS prop together

Optimization algorithms — diagram

New hyperparameters:

Optimization algorithms — diagram

Learning rate decay

Optimization algorithms — diagram

Sometimes the cost noises around the minimum value, the steps can be noisy and the algorithm might never converge

Optimization algorithms — diagram

So we decrease learning rate to ensure the algorithm learning rate is smaller when reaching center

Learning rate decay other formulaes:

Optimization algorithms — diagram

Saddle points and plateaus

Optimization algorithms — diagram

In high-dimensional spaces, true local optima are rare

However encountering saddle point is very common than a true local optima

Optimization algorithms — diagram

Plateau is a region where gradient is nearly zero over a large area, causing learning process to slow down

Adam optimizer makes learning process accelerate through these plateaus