Shampoo is an optimizer that exploits the fact that weights are matrices or tensors, keeping a small preconditioner matrix for each dimension and conditioning the gradient by sandwiching it between these matrices. It was published by Gupta, Koren, and Singer in 2018.
Methods that multiply the gradient by a matrix before taking a step are called preconditioned gradient methods. Examples include Newton's method (using the Hessian) and full-matrix AdaGrad (using the gradient covariance); because they can correct the step direction while accounting for relationships between parameters, they can converge faster. However, with parameters the preconditioner becomes , which is far too large to store or compute in deep learning. As a result, AdaGrad and Adam, which use only the diagonal, have been widely used in practice.
Rather than reducing to the diagonal, Shampoo factorizes the full matrix by exploiting the shape of the parameters. For an weight matrix, it keeps only two matrices: an matrix representing relationships among rows, and an matrix representing relationships among columns.
- Full-matrix preconditioning: An matrix, storing values, with computation for inverses and the like
- Shampoo: Two matrices, and , storing values, with computation
According to a footnote in the paper, the name Shampoo was chosen "because it has to do with preconditioning."

