09 - training

L(w,b)=1Ni=1N[y(wxi+b)]2 (w,b)L (w,b)=argminw,bL(w,b) dLdw>0loss increases as w increases move w downdLdw<0loss decreases as w increases move w up wnew=woldηdLdw

where, η is the learning rate

θt+1=θtηθL
calculate loss
      ↓
calculate gradient
      ↓
move parameters downhill
      ↓
calculate new loss
      ↓
repeat
input
  ↓
forward pass
  ↓
prediction
  ↓
loss
  ↓
backpropagation
  ↓
gradients
  ↓
optimizer
  ↓
updated weights

stochastic gradient descent

read 10,000,000 observations
          ↓
calculate gradient
          ↓
ONE parameter update
          ↓
read 10,000,000 observations again

mini-batches

100 observations
       ↓
gradient
       ↓
update parameters

next 100
       ↓
gradient
       ↓
update parameters

next 100
       ↓
...

epoch

epoch

  • an epoch means that the training process has gone through the entire training dataset approximately once

initialise parameters θ
         │
         ▼
      EPOCH 1
         │
         ├── batch 1
         │      ↓
         │   predict
         │      ↓
         │   calculate loss
         │      ↓
         │   calculate gradient
         │      ↓
         │   update θ
         │
         ├── batch 2
         │      ↓
         │     ...
         │
         └── final batch
                 │
                 ▼
         evaluate validation
                 │
                 ▼
              EPOCH 2
                 │
                ...

hyperparameter tuning