Compute the gradient of the mean logistic (cross-entropy) loss for a linear model with weights w, evaluated at bias b=0. The prediction is p=σ(Xw) and the labels y are 0/1.
Implement solve(X,y,w).
Returns. Return a tuple (grad_w, grad_b): a NumPy vector with one entry per feature, and a float. Both are averaged over the n rows.
Example 1
Input:
solve([[1.0, 2.0], [3.0, 4.0]], [1, 0], [0.0, 0.0])
Output:
([0.5, 0.5], 0.0)
Example 2
Input:
solve([[1.0], [2.0], [3.0]], [0, 1, 1], [0.5])
Output:
([-0.154233], 0.057031)
No results yet
Run your code to check it against the examples, or submit to run every test.