Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural Networks
Daniel Kunin, Giovanni Luca Marchetti, Feng Chen, Dhruva Karkada, James B. Simon, Michael R. DeWeese, Surya Ganguli, Nina Miolane
TL;DR
The paper introduces Alternating Gradient Flows (AGF), a two-step framework that models feature learning in two-layer networks trained from small initialization by alternating between dormant utility maximization and active cost minimization. AGF reproduces and unifies a range of saddle-to-saddle analyses across architectures, including diagonal linear networks, fully connected linear networks, and attention-only linear transformers, and provides a complete theory for modular addition where Fourier features are learned in decreasing frequency order. In the vanishing initialization limit, AGF converges to gradient flow in diagonal linear networks and aligns with known greedy low-rank learning dynamics, offering a principled explanation for the order and timing of feature emergence. The framework also extends to predicting Fourier feature learning in modular arithmetic and suggests broader implications for connecting optimization dynamics with mechanistic interpretability across simple two-layer models, with future work aimed at deeper architectures and more general data regimes.
Abstract
What features neural networks learn, and how, remains an open question. In this paper, we introduce Alternating Gradient Flows (AGF), an algorithmic framework that describes the dynamics of feature learning in two-layer networks trained from small initialization. Prior works have shown that gradient flow in this regime exhibits a staircase-like loss curve, alternating between plateaus where neurons slowly align to useful directions and sharp drops where neurons rapidly grow in norm. AGF approximates this behavior as an alternating two-step process: maximizing a utility function over dormant neurons and minimizing a cost function over active ones. AGF begins with all neurons dormant. At each iteration, a dormant neuron activates, triggering the acquisition of a feature and a drop in the loss. AGF quantifies the order, timing, and magnitude of these drops, matching experiments across several commonly studied architectures. We show that AGF unifies and extends existing saddle-to-saddle analyses in fully connected linear networks and attention-only linear transformers, where the learned features are singular modes and principal components, respectively. In diagonal linear networks, we prove AGF converges to gradient flow in the limit of vanishing initialization. Applying AGF to quadratic networks trained to perform modular addition, we give the first complete characterization of the training dynamics, revealing that networks learn Fourier features in decreasing order of coefficient magnitude. Altogether, AGF offers a promising step towards understanding feature learning in neural networks.
