0Pricing
Deep Learning Academy · Lesson

Minimize a Function by Hand in Python

Code gradient descent on a simple curve.

A Tiny Practice Problem

Let's run gradient descent ourselves on one simple curve. We will minimize a basic function in plain Python before trusting any framework to do it.

Pick a Function

We use a single-dip parabola. Its lowest point sits at x equal to 3, so that is the minimum our code should discover on its own.

def f(x):
    return (x - 3) ** 2

All lessons in this course

  1. Loss as a Landscape to Descend
  2. Gradients Point Uphill — So Step the Other Way
  3. Learning Rate: Too Big, Too Small, Just Right
  4. Minimize a Function by Hand in Python
← Back to Deep Learning Academy