Code accompanying the paper:
"Temporal Coding as a Substrate for Sensorimotor Object Inference: A Spiking Reinterpretation of Thousand Brains Architecture" Joy Bose
The Thousand Brains Project's Monty framework models object recognition through sequential sensorimotor exploration. Its current implementation encodes each contact as a dense feature vector, discarding the temporal order of observations.
This repository proposes replacing dense vectors with rank-order spike packets, where the firing sequence encodes spatial structure implicitly:
- The most strongly activated neuron fires first
- The time gap between packets encodes displacement without explicit coordinate transforms
- An asymmetric STDP rule encodes traversal direction into synaptic weights
- A learnable context parameter λ adapts the memory horizon to each object's geometry
On a traversal discrimination task where two objects share identical features but differ in spatial arrangement:
| Representation | Accuracy |
|---|---|
| Dense accumulation | 51.2% (chance) |
| Temporal coding | 100.0% |
Dense accumulation cannot distinguish the objects — their feature vectors sum identically regardless of order. Temporal coding discriminates them perfectly because STDP encodes the direction of traversal into the weight matrix.
src/temporal_coding/
spike_encoder.py # rank-order spike packet encoding
latency_decoder.py # implicit displacement from inter-packet latency
stdp.py # causal STDP learning rule (Bi & Poo, 1998)
adaptive_accumulator.py # evidence accumulator with learnable lambda
experiments/
traversal_discrimination.py # reproduces the key result above
tests/
test_temporal_coding.py # 17 unit tests
numpy
pytest # for tests only
No GPU, no Habitat-sim, no pretrained models required for the experiment.
To integrate with Monty, install the
tbp.monty conda environment
and copy src/temporal_coding/ into
src/tbp/monty/frameworks/models/temporal_coding/.
git clone https://github.com/joyboseroy/temporal-coding-tbt.git
cd temporal-coding-tbt
python experiments/traversal_discrimination.pyExpected output:
Overall 51.2% 100.0%
Accuracy gap: +48.8 percentage points in favour of temporal coding.
pytest tests/test_temporal_coding.py -v
# 17 passedTemporalCodingLM subclasses GraphLM and overrides only the feature
encoding and evidence accumulation. Reference frames, voting, the motor
policy, and buffer management are all inherited unchanged.
See the paper for the full architecture description.
@misc{bose2025temporal,
title={Temporal Coding as a Substrate for Sensorimotor Object Inference:
A Spiking Reinterpretation of Thousand Brains Architecture},
author={Bose, Joy},
year={2025}
}MIT. See LICENSE.