5 hidden checks

Build the two tools you will use to check and train every model in this course.

  • numerical_gradient(f, x, h=1e-5): given a function f that takes a 1-D array and returns a number, return an array the same shape as x holding the central-difference estimate of each partial derivative. Nudge one element at a time.
  • gradient_descent(grad, x0, lr, steps): start at x0 and apply x = x - lr * grad(x) steps times. Return the final x. Don't modify x0 in place.
checks
  • numerical_gradient matches an exact gradientnot run
  • numerical_gradient works in 5 dimensionsnot run
  • numerical_gradient leaves x unchangednot run
  • gradient_descent finds the minimum of a bowlnot run
  • gradient_descent takes exactly `steps` stepsnot run
python sleeps until you press run

Press Run & check. Your code runs first, then the hidden checks on the left.