Research
Predictive Coding
A .NET 10 research codebase built on one idea: the brain is a prediction machine, and perception and learning are free-energy minimisation. No backpropagation in the core, no Python — one hierarchical generative engine that grows into a model of the visual cortex, a Thousand Brains sensorimotor system, a complete Transformer stack and a live vision pipeline.
Every layer of the stack holds a latent state, generates a top-down prediction of the layer below, and learns only from the gap between what it predicted and what it received — a rule whose every term is available locally, at the layer that computes it. That single locality property is what lets the same engine become a classifier, a memory, an agent, a cortex. The code and the full documentation are on GitHub.
-
Learning without backpropagation
Local Hebbian rules
The core network settles its hidden states by minimising free energy, then updates every weight from quantities available at that layer alone — its own prediction error and the activity of the layer above. No global backward pass, no autodiff graph, no GPU required.
-
One engine, many architectures
Composition, not special cases
Modular hierarchies, active inference, temporal cascades, modern Hopfield memories, graph predictive coding, a mixture-of-experts gated by free energy, spiking networks — all built by wrapping the same core
Network, without a single new learning algorithm. -
A cortex in code
36 brain regions
A predictive-coding visual cortex (V1→V2→V4→IT) plus models of the hippocampus and grid cells, thalamus and basal ganglia, dopamine and noradrenaline, the amygdala, Broca and Wernicke — each one an assembly of already-tested primitives, not a new model to debug.
-
A Thousand Brains system
Hawkins / Numenta, in C#
Cortical columns that each learn a model of an object in their own reference frames and vote to reach consensus — the published Thousand Brains science implemented paper by paper, with pose-invariant recognition in 2-D and 3-D and a sensorimotor loop that runs on real images.
-
A Transformer stack, and a camera feed
Language and vision
A complete decoder-only Transformer — BPE tokenizer, RoPE, GQA, MLA, SwiGLU, KV cache, beam search, an autodiff trainer — and a live people counter: YOLOX detection, SORT tracking, re-identification, on CPU or CUDA.
Documentation
The project explained section by section: the mathematics it rests on, the architectures it grows, the cortex it models, the language stack it trains and the vision pipeline it runs.
-
The theory
Free energy, top-down predictions, the two nested updates and why the learning rule is local.
Read -
Architectures
The core engine — and the brain-inspired networks composed on top of it.
Read -
Cortex & brain
A predictive-coding visual cortex, 35 more regions and the Thousand Brains system.
Read -
Language
A complete decoder-only Transformer stack, from tokenizer to beam search.
Read -
Vision & GPU
Live people counting — detect, track, count — and the CPU/CUDA device layer.
Read
The whole codebase — core engine, cortex, brain, LLM, vision and the test suite behind them — lives with the source, together with the documentation these pages are based on. Pure managed .NET 10: it builds and runs without Python and falls back to the CPU when no GPU is present. matteofabbri/PredicitiveCoding on GitHub