Loading...
Loading...
You are given a list of doubles t, a list of doubles x of the same length as t, and a double y. The dot product of x and t is the sum of x[i] * t[i] over every index i of t. The loss is (d - y) ** 2, where d is the dot product of x and t.
Return the gradient of the loss with respect to t as a list of doubles. The i-th entry of the gradient is the partial derivative of the loss with respect to t[i]. That is, if L(t) is our loss L(t)=(x⋅t−y)2 then the result is
An answer within 1e-5 of the exact value (absolute or relative) is accepted.
t.length ≤1000x.length = t.lengtht[i] ≤100x[i] ≤100y ≤100t, x and y is finiteThe dot product is 2, so the loss is (2 - 3)^2 = 1. The gradient has a single entry, equal to -4.
The dot product is 11, exactly equal to y, so the loss is 0 at its minimum and every partial derivative is 0.
The dot product is 0, so the loss is (0 - 1)^2 = 1. The two partial derivatives are -2 and 2.