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) ** 2All lessons in this course
- Loss as a Landscape to Descend
- Gradients Point Uphill — So Step the Other Way
- Learning Rate: Too Big, Too Small, Just Right
- Minimize a Function by Hand in Python