NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Neurocoder: Learning General-Purpose Computation Using Stored Neural Programs

Hung Le, Svetha Venkatesh

TL;DR

Neurocoder reimagines artificial neural networks through the stored-program computing paradigm by treating weights as modular, reusable subprograms in an external memory. By storing singular value decomposition (SVD) bases of weight matrices and dynamically assembling them on the fly, Neurocoder allows neural networks to "code" themselves per input, delivering strong gains in continual learning, multi-task reasoning, and reinforcement learning.

What Problem Does This Paper Address?

Standard artificial neural networks function like single-purpose, hardwired circuits: their learned connection weights act as a single, monolithic program. Training on new tasks often overwrites previous weights—the well-known challenge of catastrophic forgetting.

Existing conditional computation alternatives have drawbacks:

  • Modular networks / Mixture of Experts (MoE) combine outputs of distinct sub-networks, but duplicating experts leads to parameter explosion and redundant computation.
  • Memory-Augmented Neural Networks (MANNs) let networks store and read data, but cannot store executable neural programs.
  • Hypernetworks and dynamic fast-weights re-scale activations or predict weights monolithically without modular reuse.

Neurocoder addresses this gap by creating a general-purpose conditional computation architecture where lightweight, modular program components are stored in external memory, shared, and dynamically assembled directly in weight space.

Methods

Neurocoder pairs a Main Network with an external Program Memory and a Program Controller:

  1. SVD-Based Program Memory: To avoid storing millions of high-dimensional weight matrices directly, the network stores low-rank subspace components—singular values and vectors—across three memory tables ($M_U, M_V, M_S$). Each memory slot stores a "singular program" acting as a unitary functional primitive.
  2. Orthogonality Regularization: An explicit orthogonal loss ($\mathcal{L}_o = \|M_U M_U^T - I\| + \|M_V M_V^T - I\|$) ensures the stored singular vectors form an efficient, non-redundant basis.
  3. Recurrent Multi-Head Program Attention: Rather than reading all components at once (which risks program collapse), a recurrent controller (LSTM) queries the memory across $J$ steps with $H$ parallel heads. It blends:
  4. Content-based attention (matching input-derived queries with compressed memory keys via cosine similarity).
  5. Usage-based attention (prioritizing least-used slots to encourage diverse memory utilization).
  6. Low-Rank Assembly & Residual Integration: Attended singular components are combined via low-rank approximation ($P_t = \sum \sigma_n u_n v_n^T$). To restore expressive high-rank capacity, an integration network adds a learned residual weight matrix ($R$), scaled by a data-dependent gating factor. The resulting working program $W_t$ is loaded into the Main Network.
  7. End-to-End Training: The entire system is fully differentiable and trained via standard backpropagation.

Datasets

The authors evaluate Neurocoder across multiple paradigms:

  • Object Recognition: MNIST, CIFAR-10, and CIFAR-100 across linear classifiers, LeNet, and DenseNet/ResNet backbones.
  • Sequential Pattern Shift: A synthetic polynomial auto-regression benchmark where inputs are sampled from piecewise polynomial functions that change abruptly over time.
  • Reinforcement Learning: Atari 2600 games (including hard-exploration/sparse-reward environments like Frostbite, Montezuma's Revenge, Seaquest, and Ms. Pacman) using an A3C framework.
  • Multi-Task Algorithmic Learning: A sequential multi-task benchmark where sequences chain 4 algorithmic sub-tasks (Copy, Repeat Copy, Associative Recall, Priority Sort), tested on lengths $n=4$ and unseen $n=8$.
  • Continual Learning: Split MNIST (5 consecutive 2-way tasks under task/domain incremental settings) and Split CIFAR-10 / Split CIFAR-100 (5-task 2-way and 20-task 5-way splits).

Key Insights and Ideas

  • Programs as Memory Data: Decomposing weight matrices into singular values and vectors makes neural weights compact enough to be stored, indexed, and retrieved just like data in a RAM.
  • Hierarchical Program Reuse: On MNIST, singular program activations naturally form a binary decision tree—similar digits (e.g., 0 and 9) share coarse structural components and only branch at higher-order singular vectors.
  • Structure Discovery in Sequences: On piecewise polynomial time series, recurrent multi-step attention automatically latches onto underlying task switches, holding the active program constant within a chunk and switching programs at chunk boundaries.
  • Fast Adaptation in Sparse Environments: In sparse Atari games (Montezuma’s Revenge), monolithic weights and fast-weight baselines fail completely, while Neurocoder's recombined modular programs discover rewarding strategies.

Key Results

  • Continual Learning: On Split MNIST, adding Neurocoder improved various continual learning algorithms (EWC, SI, L2, Adam) by 1% to 16%; Online EWC jumped from 57.78% to 73.97%. On Split CIFAR-10 and CIFAR-100 with ResNet, Neurocoder boosted accuracy by 15% and 10%, respectively.
  • Efficiency vs. Baselines: Compared to Mixture of Experts (MoE) and Neural Stored-program Memory (NSM) on CIFAR, Neurocoder achieved 8–10% higher accuracy while using roughly one-tenth the parameter count.
  • Atari 2600: In Montezuma’s Revenge and Frostbite, baseline A3C and HyperNet-A3C flatlined near zero score over 300 million steps. Neurocoder-A3C achieved scores between 1,500 and 3,000.
  • Multi-Task Generalization: When trained on sequences of 4 algorithmic tasks, only the Neurocoder-augmented Neural Turing Machine successfully zero-shot generalized to 8 chained tasks.

Limitations and Future Work

  • Hyperparameter Sensitivity: The architecture introduces several structural hyperparameters (number of singular slots, attention steps $J$, attention heads $H$, residual gates, and orthogonality weight $a$), complicating tuning.
  • Layer Coverage: Current implementations primarily replace the final feed-forward layer of deep networks (ResNet, DenseNet, GRU) rather than dynamically generating convolutional or attention kernels throughout the entire model.
  • Fixed Memory Capacity: The memory size is static during training. Future iterations aim to allow dynamic allocation—expanding or pruning program slots as the environment complexity demands.

Summary updated

BibTeX
@inproceedings{le2021neurocoder,
  author = {Hung Le and Svetha Venkatesh},
  title = {{Neurocoder: Learning General-Purpose Computation Using Stored Neural Programs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=O0ow9RQW1nP},
}
Figure