Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-289

Quadratic Gradient Descent Two Steps

Problem

Starting from x0, apply two gradient descent steps with learning rate lr on f(x) = 0.5 * a * x^2, whose gradient is a * x.

Given x0, lr, and a, return the value after two steps.

Hint

Each step multiplies the current value by (1 - lr * a).

Test cases

case 1
in: [1,0.1,2]
expected: 0.64
case 2
in: [2,0.5,1]
expected: 0.5
case 3
in: [0.5,0.25,4]
expected: 0
Starter codePython
def quadratic_gradient_descent_two_steps(x0, lr, a):
    # Your code here
    pass

3 test cases · run your code against them in the editor