Codiqo

Understanding AI · lesson 19 of 60 · about 6 minutes

Step Size

How big should each nudge be? Too big and you overshoot; too small and you never get there.

What you'll learn

  • Explain what the step size controls
  • Spot a step size that's too big
  • Spot a step size that's too small

How far to step

Each nudge has a size, often called the learning rate. It's a balance:

  • Too big, and the model jumps right over the best value and bounces back and forth.
  • Too small, and it creeps towards the best value so slowly that training takes forever.

Walking w towards the best value of 5, from 0. With steps of 1 it lands on 5; with steps of 4 it jumps past to 8.

w = 0
for step in range(5):
    w = w + 1
print(w)

w = 0
for step in range(2):
    w = w + 4
print(w)

Output

5
8

Tip

range(5) repeats the indented lines 5 times.

Now try it yourself

This lesson is free in Codiqo, with 6 questions on what you just read. You can only learn to code by writing code, so it ends with a short program you write yourself, which we run and check straight away.