Bitpath

Lesson 2 · Unit 02

Gradients

One slope per input, and the step that goes downhill

13 exercisesabout 3 min

What you practise

  • Partial derivatives, the gradient as the direction of steepest climb, gradient descent as "step downhill", the learning rate and what too big does

Try a question from this lesson

Pick one

On a hillside, each metre you walk east lifts you 3 m, and each metre north lifts you 1 m. In which direction is the climb steepest?

Hint

Going east alone wastes the lift that north offers. How would you use both?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Partial derivatives

A function can have several inputs. A loss depends on every weight in the model.

A partial derivative is the slope when you nudge one input and freeze the others. It is written with a curly d: ∂f/∂x, read "partial f, partial x".

To compute one, treat every other input as a plain number and use the usual rules.

f(x, y) = x² + 3y

∂f/∂x = 2x    (y is frozen)
∂f/∂y = 3     (x is frozen)

Concept

The gradient

Put all the partial derivatives in one vector and you have the gradient, written ∇f ("grad f").

The gradient points in the direction where f climbs fastest. Its opposite, minus the gradient, is the fastest way down.

Gradient descent uses exactly that: new point = old point - learning rate × gradient.

f(x, y) = x² + y²

∇f = [2x, 2y]

at (3, 1):  ∇f = [6, 2]

10 more exercises in the app

  • 3× type the answer
  • 3× multiple choice
  • 1× fill the blanks
  • 1× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy