# Shampoo (2018)

> Preconditions each weight matrix with two small matrices, one for its rows and one for its columns, instead of treating its weights as independent numbers.

Page: https://mralbu.github.io/ai-datasets/p/shampoo

## Key facts

- Title: Shampoo: Preconditioned Stochastic Tensor Optimization
- Authors: Vineet Gupta, Tomer Koren, Yoram Singer
- Venue: ICML 2018
- Category: Foundations
- Paper: https://www.alphaxiv.org/abs/1802.09568

## Why it matters

It made a structured second-order optimizer practical for deep networks. A distributed version won the external-tuning track of the AlgoPerf training-speed benchmark in 2024, and Muon can be read as Shampoo with the accumulation removed, which leaves an orthogonalized update.

## The idea

Full-matrix AdaGrad would capture how all the weights' gradients move together, but for a layer with m×n weights it needs a matrix with (mn)² entries. Shampoo keeps one m×m matrix of accumulated gradient statistics for the rows and one n×n matrix for the columns, and multiplies each gradient by their inverse fourth roots from left and right. The same idea extends to convolution kernels and other tensors, with one small matrix per dimension.

## The result

Swapped into existing training code with no other changes, Shampoo lowered the training loss faster than SGD with momentum, AdaGrad and Adam for ResNet and Inception networks on CIFAR-10 and a ResNet on CIFAR-100, and reached lower test perplexity for a Transformer language model on LM1B, while running about as many steps per second.

## The data

- [CIFAR-10 (2009)](https://mralbu.github.io/ai-datasets/d/cifar10.md): 60,000 tiny 32×32 color images in 10 classes.
- Also tested on: CIFAR-100 and the One Billion Word language-modeling benchmark (LM1B).

## Builds on

- [AdaGrad (2010)](https://mralbu.github.io/ai-datasets/p/adagrad.md)

## Led to

- [Muon (2025)](https://mralbu.github.io/ai-datasets/p/muon.md)

## Part of

- [Optimizers](https://mralbu.github.io/ai-datasets/t/optimizers.md) (step 6 of 7)
