Calculus and gradients practice problems
14 problems · 0 solved
Training a model means walking downhill on a loss surface, and the gradient tells you which direction is downhill. Calculus for ML is mostly about deriving those gradients correctly and checking them with code. These problems move between paper derivations and numerical verification. You will derive the gradient of mean squared error for a linear model, check a gradient with central differences, build a Jacobian with finite differences, differentiate a quadratic form when the matrix is not symmetric, derive the gradients of cosine similarity and of softmax plus cross-entropy, compute the Hessian of the logistic regression loss, choose a step size with Armijo backtracking, push a gradient through tanh by the chain rule, take a Hessian-free Newton step, and differentiate a validation loss through a ridge regression solution. Start with the Easy problems on MSE gradients and gradient checking. Then work through the softmax and logistic Hessian derivations, and finish with Newton steps and differentiating through a solver. Interviewers often ask you to derive a gradient on a whiteboard, and a habit of gradient checking catches silent bugs that would otherwise waste days of training.
Easy 5
Medium 5
- Derive the gradient of softmax plus cross-entropy
- Derive the gradient of cosine similarity with respect to one vector
- Compute the Hessian of the logistic regression loss
- Choose a step size with Armijo backtracking line search
- Differentiate the Gaussian negative log-likelihood with respect to mean and log sigma