Skip to content
DeepForgeby svx
All problems
EasyCalculusca-317

Sum of Squares Gradient Vector

Problem

For f(w) = sum_i (w_i - t_i)^2, the gradient is 2 * (w_i - t_i) for each coordinate.

Given the parameter vector w and target vector t, return the gradient list.

Hint

Differentiate each squared residual independently.

Test cases

case 1
in: [[1,2],[0,0]]
expected: [2,4]
case 2
in: [[1,1],[1,1]]
expected: [0,0]
case 3
in: [[0,3,-2],[1,1,1]]
expected: [-2,4,-6]
Starter codePython
def sum_of_squares_gradient_vector(w, t):
    # Your code here
    pass

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