All problems
Gradient Descent Two Steps
Problem
Run two gradient descent steps on f(x, y) = a*x^2 + b*y^2 + c*x*y starting from point, with learning rate lr.
The gradient is [2*a*x + c*y, 2*b*y + c*x]. At each step move the point against the gradient computed at the current location, and return the final point as [x, y].
Hint
Recompute the gradient at the new point before taking the second step.
Test cases
case 1
in: [[1,1],0.1,1,1,0]
expected: [0.64,0.64]
case 2
in: [[2,0],0.25,1,1,0]
expected: [0.5,0]
case 3
in: [[0,0],0.5,1,1,0]
expected: [0,0]
case 4
in: [[1,2],0,1,1,0]
expected: [1,2]
case 5
in: [[1,1],0.5,0,0,1]
expected: [0.25,0.25]
Starter codePython
def gradient_descent_two(point, lr, a, b, c):
# Return the point after two steps
# Your code here
pass5 test cases · run your code against them in the editor