Gradient Descent
Easy
Parameter Update Step
Easy
~10 min
code completion
The Gradient Descent Update
At its core, gradient descent is a single rule applied repeatedly:
where:
Subtracting the gradient moves parameters in the direction that decreases the loss.
Your task:
Implement gradient_step(weights, gradient, learning_rate) that returns the updated weights after one gradient descent step.
Example Tests
Standard update reduces weights
Input: {"weights":[1,2],"gradient":[0.5,-1],"learning_rate":0.1}
Expected: [0.95,2.1]
All-zero gradient: weights unchanged
Input: {"weights":[5,5],"gradient":[0,0],"learning_rate":0.5}
Expected: [5,5]
Large learning rate scales gradient
Input: {"weights":[0,0,0],"gradient":[1,2,3],"learning_rate":0.01}
Expected: [-0.01,-0.02,-0.03]