- Jupyter Notebook 83.8%
- Python 16.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| analysis | ||
| data | ||
| figures | ||
| models | ||
| notebooks | ||
| structural_tests | ||
| README.md | ||
Cerebellar manifold rotation
Simulation code for Garcia-Garcia, Wójcik, et al. (2026). Granule cells reorient cortical manifolds to separate contexts but preserve their geometry. bioRxiv.
General audience summary
To learn efficiently, a brain has to do two things that pull against each other. It has to recognise what different situations have in common, so that experience in one transfers to the next. And it has to keep those situations distinct, so that learning a new task does not overwrite an old one. Solving both at once is hard: shared representations transfer well but interfere with one another, and fully separate representations avoid interference but make every new task slow to learn.
The accompanying paper proposes a division of labour between two brain regions that addresses this directly. The cerebral cortex represents tasks on a small number of shared, smooth axes — a compact reusable scaffold that supports fast learning. The cerebellum, despite its enormous capacity to expand information into a high-dimensional code, declines to do so. It instead takes the cortical scaffold and rotates it as a rigid object, separating contexts without distorting their internal structure. The cortex provides a generic dynamical template; the cerebellum reorients that template differently for each context.
The simulations in this repository test this idea. They show that a cerebellar model that rotates a low-dimensional input — rather than shattering it into a sparse, high-dimensional code — learns as quickly as a model with no separation mechanism at all whilst suffering as little interference between tasks as a fully expansive sparse-coding model.
Background
Low-dimensional neural manifolds support generalisation across related tasks but produce interference when overlapping representations must drive distinct downstream policies. Canonical theories of cerebellar granule cell (GrC) function resolve this by sparse, high-dimensional expansion that orthogonalises inputs. Such expansion, however, fragments the topology required for smooth interpolation along the manifold and inflates the sample complexity of continuous prediction.
The accompanying paper reports that GrCs do not implement this canonical expansion. GrC populations instead preserve the low-rank geometry of their cortical input and separate contexts by applying coherent affine transformations — rotating overlapping cortical manifolds apart whilst leaving their intrinsic structure intact.
Geometric division of labour
The paper's central proposal is an architectural division of labour between cortex and cerebellum:
- The neocortex maintains low-rank, reusable manifolds that generalise across contexts and support rapid learning by linear interpolation along task-relevant axes.
- The cerebellar GrC layer applies context-dependent affine transformations to these manifolds. Affine maps preserve local Euclidean distances — a constraint imposed by the near-linear Purkinje cell readout — and so reorient contexts without distorting within-context geometry.
In this account, the cortex generates invariant dynamic primitives and the cerebellum reconfigures them, with both computations operating on the same low-dimensional substrate.
Scope of this repository
This repository implements the simulations in Figure 5k–p and Extended Data Figure 6. Three cerebellar-inspired architectures are compared on a continual-learning task with two overlapping circular input manifolds embedded in ℝ¹⁰⁰ and two angularly rotated target manifolds, trained in alternating 100-epoch phases. All three architectures share the same fixed mossy-fibre→GrC connectivity (4-input convergence, 100× expansion) and the same plastic linear readout; they differ only in the GrC representation:
| Model | GrC representation | Manifold geometry |
|---|---|---|
| Relay | dense, identity-like expansion | preserved, overlapping across contexts |
| Expansion | sparse coding with L2-normalised inputs and negative bias (Albus/Marr) | shattered into a high-rank, near-orthogonal code |
| Rotation | dense expansion preceded by a context-dependent affine transform | preserved within context, rotated apart across contexts |
The Rotation model converges as rapidly as the Relay model and exhibits cross-task interference comparable to the Expansion model. The Relay model learns rapidly but suffers catastrophic interference; the Expansion model resists interference but learns slowly because the shattered representation requires the readout to reconstruct a high-rank target.
A control experiment (Extended Data Fig. 6k–o) tests whether input geometry alone accounts for the Expansion model's slow learning. A sinusoidal shattering transform is applied to the Relay model's input manifold across a range of severities. Increasing input shattering does not reproduce the Expansion model's learning dynamics, indicating that sparse gradient flow through the GrC layer — rather than input geometry per se — is the dominant determinant of learning speed in the Expansion model.
Modules
toy_cerebellum.py—ToyCerebellum, a configurable three-stage model (rotation → expansion → readout). Each stage is toggled to instantiate Relay, Expansion, or Rotation variants.expansion_layers.py—ExpansionLayer(sparse cerebellar expansion with optional L2 normalisation, ReLU, and Golgi-cell-like negative bias) andRotationLayer(context-dependent affine transform applied in the input's intrinsic coordinates, with explicit in-plane and out-of-plane components).generators.py—CircularManifoldfor 2D circular manifolds embedded in ℝ¹⁰⁰ with controlled in-plane shear, out-of-plane translation, and angular rotation between input and target. Includes the sinusoidal shattering transform used in the geometry control.training.py— the alternating four-phase curriculum (Task 1 → Task 2 → Task 1 → Task 2, 100 epochs each), DataLoader-based mini-batch training over multiple seeds, and per-batch tracking of loss on the inactive task ("ghost loss") as an online interference measure.analysis_tools.py— PCA and participation ratio, Jaccard overlap of active GrC populations across contexts, exponential-decay fits to training loss for learning-speed estimation, andcompute_training_metricsfor consolidated summaries.viz_tools.py— figure functions:plot_training_results(main multi-panel figure),plot_shattered_results(geometry control), andplot_training_schedule(manifold geometry and curriculum).checkpoints.py— model reconstruction from saved state dicts.test.py— cross-seed initialisation sanity checks.
Citation
Garcia-Garcia, M. G., Wójcik, M. J., Thota, S., Drake, L., Otchere, A., Akinwale, O., Ramos, L., Costa, R. P., & Wagner, M. J. (2026). Granule cells reorient cortical manifolds to separate contexts but preserve their geometry. bioRxiv. https://doi.org/10.64898/2026.03.03.709240