English

Fourier Circuits in Neural Networks and Transformers: A Case Study of Modular Arithmetic with Multiple Inputs

Machine Learning 2025-03-11 v4 Machine Learning

Abstract

In the evolving landscape of machine learning, a pivotal challenge lies in deciphering the internal representations harnessed by neural networks and Transformers. Building on recent progress toward comprehending how networks execute distinct target functions, our study embarks on an exploration of the underlying reasons behind networks adopting specific computational strategies. We direct our focus to the complex algebraic learning task of modular addition involving kk inputs. Our research presents a thorough analytical characterization of the features learned by stylized one-hidden layer neural networks and one-layer Transformers in addressing this task. A cornerstone of our theoretical framework is the elucidation of how the principle of margin maximization shapes the features adopted by one-hidden layer neural networks. Let pp denote the modulus, DpD_p denote the dataset of modular arithmetic with kk inputs and mm denote the network width. We demonstrate that a neuron count of m22k2(p1) m \geq 2^{2k-2} \cdot (p-1) , these networks attain a maximum L2,k+1 L_{2,k+1} -margin on the dataset Dp D_p . Furthermore, we establish that each hidden-layer neuron aligns with a specific Fourier spectrum, integral to solving modular addition problems. By correlating our findings with the empirical observations of similar studies, we contribute to a deeper comprehension of the intrinsic computational mechanisms of neural networks. Furthermore, we observe similar computational mechanisms in attention matrices of one-layer Transformers. Our work stands as a significant stride in unraveling their operation complexities, particularly in the realm of complex algebraic tasks.

Keywords

Cite

@article{arxiv.2402.09469,
  title  = {Fourier Circuits in Neural Networks and Transformers: A Case Study of Modular Arithmetic with Multiple Inputs},
  author = {Chenyang Li and Yingyu Liang and Zhenmei Shi and Zhao Song and Tianyi Zhou},
  journal= {arXiv preprint arXiv:2402.09469},
  year   = {2025}
}

Comments

AIStats 2025

R2 v1 2026-06-28T14:48:51.603Z