Gradient Descent
Easy
Implement the Gradient Descent Update
Easy
~10 min
code completion
Gradient Descent Parameter Update
Gradient descent is the core optimization algorithm in machine learning. In each step, we move parameters in the direction that reduces the loss.
The update rule for a single parameter is:
where:
Your task:
Implement gradient_step that applies one gradient descent update to an array of parameters.
Watch out for:
Example Tests
Correct update with lr=0.1
Input: {"params":[2,-1],"gradients":[4,-2],"learning_rate":0.1}
Expected: [1.6,-0.8]
Zero gradients leave params unchanged
Input: {"params":[5,3],"gradients":[0,0],"learning_rate":0.5}
Expected: [5,3]
Gradient sign error detection
Input: {"params":[1],"gradients":[1],"learning_rate":0.1}
Expected: [0.9]