A super-simplified, single-file PyTorch replica of the Continuous Thought Machine (CTM) from Sakana AI.
Modern AI often ignores the timing and synchronization in biological brains for efficiency. CTM bridges that gap, using neural dynamics as the core of computation. This simplified version distills the essence of the original repo into one Python file (ctm.py), training on MNIST to classify digits while demonstrating key CTM concepts like neuron synchronization and temporal thinking.
Inspired by the original work: Continuous Thought Machines and Sakana AI.
Install directly from the repository:
pip install git+https://github.com/xandykati98/SimpleCTM.gitOr install in editable mode for development:
git clone https://github.com/xandykati98/SimpleCTM.git
cd SimpleCTM
pip install -e .-
Clone the repo:
git clone https://github.com/xandykati98/SimpleCTM.git cd SimpleCTM -
Install dependencies:
pip install -r requirements.txt
(Requires PyTorch, Torchvision – check
requirements.txtfor details)
After installation, you can import and use SimpleCTM in your code:
from simplectm import ctm
# Use the CTM models and utilitiesRun my experiments using the Modal API:
modal run simplectm/modal_experiment.py # This will run last experiment I am doing on the modal_experiment.py
modal run simplectm/modal_router.py::run_training_imagenette # Or by targeting a specific experiment on the modal_router.py
Run the training script:
python -m simplectm.ctm Or if running from the repository root:
python simplectm/ctm.py This will:
- Download MNIST
- Train the SimplifiedCTM model for 10 epochs
- Print progress and accuracy
- Save the model to
ctm_spatial_model
Customize hyperparameters in main() – like number of neurons, max ticks, epochs.
For full details, dive into ctm.py or the original Sakana AI CTM page.
Built with ❤️ by xandykati98
