TopicGradient descent
Title
Two steps of gradient descent
ExampleW03.1
Step1 / 5
Mode
Given
Given
Fit the line to the three points by gradient descent on . Start from with learning rate and take two steps, updating and together.
- Points , , , so
| 0 | |||
| 1 | |||
| 2 |
Read the problem
Each row of the table is one value of and its cost. A step moves both parameters against the gradient, and .
Sim
Gradient descent on the three points
Drag the start on the contours of , change or the number of steps. The table fills step by step; past the largest that converges, the steps overshoot and grows.
- Assumed
- supplied here, not in the Materials: and tuned from to in steps of · tuned from to in steps of · up to steps
| 0 | 0.0000 | 0.0000 | 4.3333 |
| 1 | 0.2667 | 0.3667 | 2.5231 |
| 2 | 0.4700 | 0.6456 | 1.4741 |
After 2 steps: = 0.4700, = 0.6456, = 1.4741
Python
The same line by the normal equation
Real Python with numpy: the line gradient descent steps towards, solved in one step by . Edit the code and run it live.
The plot and output the code gave at build. Run live downloads Python (16.5 MB) and runs the code as you edit it.
Output
theta0 = 1.1667 theta1 = 1.5000 J(theta) = 0.0278