Verify a batch gradient update
Implement gradient_step(xs, ys, w, b, learning_rate) for scalar linear predictions. Use mean half-squared error over equal nonempty sequences. Return (new_w, new_b, loss_before_update), updating both parameters from the same original snapshot. Require finite numeric inputs, reject booleans, and require a finite nonnegative learning rate. The test suite checks actual calculus with a finite-difference comparison.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
EXAMPLE 1
Inputgradient_step([2], [5], 1, 0, 0.1)
Output(1.6, 0.3, 4.5)
EXAMPLE 2
Inputgradient_step([1], [2], 2, 0, 0.1)
Output(2.0, 0.0, 0.0)
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor