Skip to content

A single-file implementation of the Continuous Thought Machines by Sakana AI

License

Notifications You must be signed in to change notification settings

xandykati98/SimpleCTM

Repository files navigation

SimpleCTM

CTM Diagram

A super-simplified, single-file PyTorch replica of the Continuous Thought Machine (CTM) from Sakana AI.

TL;DR

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.

Installation

Option 1: Install as a package (Recommended)

Install directly from the repository:

pip install git+https://github.com/xandykati98/SimpleCTM.git

Or install in editable mode for development:

git clone https://github.com/xandykati98/SimpleCTM.git
cd SimpleCTM
pip install -e .

Option 2: Manual installation

  1. Clone the repo:

    git clone https://github.com/xandykati98/SimpleCTM.git
    cd SimpleCTM
  2. Install dependencies:

    pip install -r requirements.txt

    (Requires PyTorch, Torchvision – check requirements.txt for details)

Usage

As a Python package

After installation, you can import and use SimpleCTM in your code:

from simplectm import ctm
# Use the CTM models and utilities

Running scripts directly

Run 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

About

A single-file implementation of the Continuous Thought Machines by Sakana AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •