[Paper Review] Grokking modular arithmetic
This paper presents a minimal two-layer fully connected neural network that learns modular arithmetic tasks via vanilla gradient descent with MSE loss, exhibiting grokking—sudden, delayed generalization—without regularization. It analytically derives the feature maps responsible for grokking and shows they are recovered by both gradient descent and AdamW, establishing full interpretability of the learned representations.
We present a simple neural network that can learn modular arithmetic tasks and exhibits a sudden jump in generalization known as ``grokking''. Concretely, we present (i) fully-connected two-layer networks that exhibit grokking on various modular arithmetic tasks under vanilla gradient descent with the MSE loss function in the absence of any regularization; (ii) evidence that grokking modular arithmetic corresponds to learning specific feature maps whose structure is determined by the task; (iii) analytic expressions for the weights -- and thus for the feature maps -- that solve a large class of modular arithmetic tasks; and (iv) evidence that these feature maps are also found by vanilla gradient descent as well as AdamW, thereby establishing complete interpretability of the representations learnt by the network.
Motivation & Objective
- To demonstrate grokking in a minimal, fully connected two-layer network without regularization.
- To analytically derive the feature maps that solve a broad class of modular arithmetic tasks.
- To show that these feature maps are learned by standard optimization methods like vanilla GD and AdamW.
- To establish complete interpretability of representations in a grokking scenario.
- To provide a solvable model for studying generalization dynamics in deep learning.
Proposed method
- Uses a two-layer fully connected ReLU network without biases, trained with vanilla gradient descent and MSE loss.
- Derives analytic expressions for network weights that solve modular arithmetic tasks via Fourier-based feature maps.
- Employs preactivations and their Fourier transforms to identify learned functional structure.
- Compares trained network weights to analytic solutions to confirm alignment.
- Uses phase tuning in the analytic solution to suppress spurious features and match training dynamics.
- Validates results across multiple optimizers (vanilla GD and AdamW), showing consistent recovery of feature maps.
Experimental results
Research questions
- RQ1Can grokking occur in a minimal, regularized-free neural network trained with standard optimization on modular arithmetic tasks?
- RQ2What analytic form do the learned feature maps take, and how do they relate to the task structure?
- RQ3Do standard optimization methods like AdamW recover the same interpretable feature maps as the analytic solution?
- RQ4How does the structure of the loss landscape and training dynamics relate to the onset of generalization?
- RQ5Can the critical data size for grokking be characterized as a function of task complexity and modulus?
Key findings
- The network exhibits grokking on modular arithmetic tasks under vanilla gradient descent with MSE loss, without any regularization.
- Analytic solutions for the network weights are derived, corresponding to feature maps that solve a large class of modular arithmetic tasks.
- The learned representations from gradient descent and AdamW fully match the analytic feature maps, confirming interpretability.
- The onset of generalization coincides with a sharp rise in weight norms and a peak in test loss, indicating a transition to generalization.
- The Fourier transform of preactivations reveals a single dominant peak corresponding to the correct modular relation, such as m+n=6 mod 97.
- The critical data fraction αc for grokking is empirically found to decrease with increasing modulus p, suggesting larger moduli are simpler to learn.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.