Cortex & brain
A predictive-coding model of the visual cortex and 35 other brain regions, plus a Thousand Brains sensorimotor system — every one of them an assembly of already-tested primitives rather than a new learning algorithm to debug.
The visual cortex
VisualCortex models the ventral stream — the path from
raw pixels to abstract object identity — using exactly one new
primitive, the RetinotopicMap, and reusing the rest:
image [C,H,W]
│ RetinotopicMap : tile into overlapping P×P receptive fields
▼
V1 : one weight-shared cortical-column PCN applied at every position (= convolution)
│ concatenate over the grid → V1 feature map
▼
V2…IT: HierarchicalNetwork (deep modular hierarchy) → abstract object latent
▼
readout (optional): PCN classifier on the IT latent
The retinotopic map extracts an image into overlapping patches and assembles them back overlap-averaged — that is the receptive-field machinery. Everything else is the standard engine: the shared V1 column autoencodes every patch (learning Gabor-like features, exactly as Rao & Ballard described), each higher area greedily encodes the one below, and the readout classifies by minimum free energy.
The cortical areas
The other regions are organised by system. Most are thin wrappers
around the architectures of the previous page; the pure controllers
(Thalamus, BasalGanglia, the
neuromodulators) hold no persistent state and only emit signals.
Sensory
| Area | What it is |
|---|---|
| AuditoryCortex | Tonotopic A1→belt→parabelt: the visual hierarchy applied to a 1-channel spectrogram. |
| SomatosensoryCortex | Somatotopic S1: the same microcircuit on a skin map. |
| DorsalStream | The "where/how" path: a per-frame visual cortex plus a deep recurrent network for motion. |
| RetinaLgn | Center-surround (difference-of-Gaussians) whitening front-end. |
| OlfactoryBulb | Decorrelating gain control feeding the piriform cortex. |
| GustatoryCortex | Taste content-addressable memory (a Hopfield attractor). |
| VestibularSystem | Self-motion integration into a head-direction code; partner of the grid cells. |
| FrontalEyeFields | Saccade selection: saliency plus inhibition-of-return over the retinotopic map. |
Memory — the medial temporal lobe
| Area | What it is |
|---|---|
| HippocampalFormation | Fast episodic store (Hopfield) plus offline replay consolidating into a neocortex (McClelland 1995). |
| EntorhinalCortex + GridCellEncoder | A hexagonal grid-cell code for 2-D position, plus a predictive spatial association. |
| PiriformCortex | Olfactory content-addressable memory. |
| PerirhinalCortex | Item familiarity and novelty: recognition memory. |
| ParahippocampalCortex | Scene and context gist — the "place area". |
Executive and motor
| Area | What it is |
|---|---|
| PrefrontalCortex | Gated working memory plus a hierarchical mixture of experts for task selection. |
| MotorCortex | An active-inference control loop that reaches for goals. |
| CerebellarCortex | A fast supervised forward model: given state and command, predict the next state. |
| PremotorCortex / SMA | Action sequencing: a temporal mixture of experts predicts the next action and feeds the motor cortex. |
Integration and control
| Area | What it is |
|---|---|
| AssociationCortex | Multimodal binding across the senses. |
| Thalamus | Precision and gain controller: allocates gain across areas by inverse free energy. |
| BasalGanglia | Action selection by energy gating — go/no-go. |
| DefaultModeNetwork | Offline generative imagination via sampling from the generative prior. |
| PosteriorParietalCortex | Coordinate transforms and intentional maps — the dorsal-to-motor bridge. |
| Claustrum | Global binding: a consensus broadcast (mean latent) and workspace coherence. |
Neuromodulation
| System | What it does |
|---|---|
| DopaminergicSystem | VTA/SNc dopamine: reward-prediction error with an average-reward baseline; modulates plasticity. |
| LocusCoeruleus | Noradrenaline: a global-surprise monitor whose phasic burst applies a broad precision reset across areas. |
| NucleusBasalis | Acetylcholine: per-area expected uncertainty that modulates each area's learning rate. |
| RapheNuclei | Serotonin: time horizon and patience, translated into the temporal-discount factor. |
Limbic and affective
| Area | What it is |
|---|---|
| Amygdala | Affective salience and valence; emits a salience gain that steers the thalamus. |
| OrbitofrontalCortex | Expected-value model feeding the basal ganglia. |
| CingulateCortex | Conflict and surprise monitor over area free energies — calls for top-down control. |
| InsularCortex | Interoception: integrates the body-state stream into a feeling latent. |
| Hypothalamus | Homeostatic set-points → drives, and the goal observation for the motor cortex. |
Language
| Area | What it is |
|---|---|
| WernickeArea | Comprehension: maps a token sequence to a semantic latent. |
| BrocaArea | Production: decodes a semantic latent into an utterance, paired with the motor cortex. |
| AngularGyrus | A relational semantic hub: completes a concept from its related concepts on a graph. |
A Thousand Brains system
PredictiveCoding.Brain implements the Hawkins/Numenta
papers (P1–P9, from A Thousand Brains to the 2025
sensorimotor-intelligence work) as a hard rule: a task stays on the
roadmap only if it traces back to one of them. The end state —
shipped, with the roadmap closed — is many cortical columns that each
learn a model of an object in their own reference frames and
vote to reach consensus:
- Reference frames — grid-cell-style pose encoding in 2-D and full 3-D (SE(3), quaternion algebra), with motor-driven path integration closing the loop.
- Voting — columns exchange evidence and converge on the object and pose consistent with all of them, so recognition works from partial, moving observation.
- Pose invariance — recognition from pairwise displacement signatures survives arbitrary rigid motion and occlusion, in 2-D and 3-D.
- Real sensors — a movable patch sensor scans real images; the same sensorimotor loop runs unchanged on camera frames.
- Cross-modal voting — columns over different modalities agree on the same object.
A benchmark and demo ship with it (demo option 9), rendering an animated, self-contained web page with the episode player, the benchmark and a real-sensor scan; 109 unit tests cover the stack.
The desktop demo
A WinUI 3 app trains and visualises several of these models, one page per example running on a background thread: the visual cortex classifying and reconstructing noisy shapes, Hopfield pattern completion, entorhinal grid-cell firing maps, a spiking network, and an active-inference agent learning a world model and reaching a goal.