MLCrack

    ML MATH & LINEAR ALGEBRA · INTERVIEW QUESTION

    What are gradients, Jacobians, and Hessians? When do you use each in ML?

    🟡 intermediate · Calculus & Optimization

    Hint: First derivative vector, first derivative matrix, second derivative matrix.

    Answer

    Gradient (∇f): vector of partial derivatives of a scalar function f. Points in the direction of steepest ascent. Used in: gradient descent for optimizing loss functions. Jacobian (J): matrix of partial derivatives of a vector-valued function. J_{ij} = ∂f_i/∂x_j. Used in: backpropagation (chain rule with Jacobians), normalizing flows (determinant of Jacobian for density transformation). Hessian (H): matrix of second partial derivatives. H_{ij} = ∂²f/∂x_i∂x_j. Used in: Newton's method (x ← x - H⁻¹∇f for quadratic convergence), analyzing loss landscape curvature, natural gradient methods, understanding optimization difficulty (condition number of Hessian). Computing full Hessian is O(n2)O(n²) — approximations used in practice (L-BFGS, Fisher information matrix).