### Install TensorBoard for Training Monitoring Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/rl/README.md This command installs TensorBoard, a crucial tool for visualizing and monitoring the progress of RL training. It is a necessary prerequisite for effective training observation. ```bash pip install tensorboard ``` -------------------------------- ### Install HuggingFace Hub for Dataset Access Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/image_classification/README.md This command installs the `huggingface_hub` library, which is a prerequisite for accessing and downloading the ILSRC/imagenet-1k dataset from Hugging Face. It's essential for setting up the environment to run image classification experiments. ```bash pip install huggingface_hub ``` -------------------------------- ### Conda Environment and Dependency Installation Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/README.md This command sequence demonstrates how to initialize a new Python environment using Conda, activate it, and then install all necessary project dependencies listed in the `requirements.txt` file. This is the primary method for setting up the development environment. ```bash conda create --name=ctm python=3.12 conda activate ctm pip install -r requirements.txt ``` -------------------------------- ### VSCode Debug Configuration for Image Classifier Training Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/README.md An example VSCode launch configuration for debugging the image classification training script. It uses the `debugpy` type, launches the module, and displays output in the integrated terminal, allowing debugging of external code. ```json { "name": "Debug: train image classifier", "type": "debugpy", "request": "launch", "module": "tasks.image_classification.train", "console": "integratedTerminal", "justMyCode": false } ``` -------------------------------- ### Troubleshooting PyTorch Installation Issues Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/README.md In cases where the default PyTorch installation causes conflicts or fails, these commands provide a workaround. They first uninstall any existing PyTorch versions and then reinstall a specific CUDA-enabled version (cu121) directly from the PyTorch index URL. ```bash pip uninstall torch pip install torch --index-url https://download.pytorch.org/whl/cu121 ``` -------------------------------- ### Install FFmpeg with Conda Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/README.md Command to install the `ffmpeg` library using `conda` from the `conda-forge` channel. FFmpeg is a crucial dependency for generating MP4 video files from the analysis scripts provided in the project. ```bash conda install -c conda-forge ffmpeg ``` -------------------------------- ### Run Image Classifier Training Module Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/README.md Command to execute the image classification training script as a Python module from the top-level directory. This setup is designed to facilitate running high-level training scripts easily. ```python python -m tasks.image_classification.train ``` -------------------------------- ### Run Q&A MNIST Analysis with Checkpoints Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/qamnist/README.md Initiates the analysis script for the Q&A MNIST project. This command requires specifying the directory where model checkpoints are stored using the `--log_dir` argument. Checkpoints can be generated by running the training code or downloaded from the provided Google Drive link. ```python python -m tasks.qamnist.analysis.run --log_dir ``` -------------------------------- ### Run Single GPU ImageNet Training with Python Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/image_classification/README.md This command executes image classification training on the ImageNet dataset using a single GPU. It sets up the model and training process with parameters similar to the distributed configuration, including mixed precision and specific logging details. The `--device 0` flag explicitly targets the first available GPU. ```bash python -m tasks.image_classification.train --d_model 4096 --d_input 1024 --synapse_depth 12 --heads 16 --n_synch_out 150 --n_synch_action 150 --neuron_select_type random --iterations 75 --memory_length 25 --deep_memory --memory_hidden_dims 64 --dropout 0.05 --no-do_normalisation --positional_embedding_type none --backbone_type resnet152-4 --batch_size 60 --batch_size_test 64 --lr 5e-4 --training_iterations 500001 --warmup_steps 10000 --use_scheduler --scheduler_type cosine --weight_decay 0.0 --log_dir logs-lambda/imagenet-distributed-4april/d=4096--i=1024--h=16--ns=150-random--iters=75x25--h=64--drop=0.05--pos=none--back=152x4--seed=42 --dataset imagenet --save_every 2000 --track_every 5000 --seed 42 --n_test_batches 50 --use_amp --device 0 ``` -------------------------------- ### Run 2D Maze Experiment Analysis and Visualization Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/mazes/analysis/README.md This command executes the Python script for 2D maze analysis, specifically enabling visualization actions. It requires a pre-trained model checkpoint, which must be downloaded or generated, to be specified via the `--checkpoint` argument for the analysis to proceed. ```Python python -m tasks.mazes.analysis.run --actions viz viz --checkpoint checkpoints/mazes/ctm_mazeslarge_D=2048_T=75_M=25.pt ``` -------------------------------- ### Project Repository Structure Overview Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/README.md This snippet provides a detailed hierarchical view of the project's file system, illustrating the organization of tasks, data, models, and utility modules. It helps in understanding where different components of the Continuous Thought Machines project are located. ```filesystem ├── tasks │   ├── image_classification │   │   ├── train.py # Training code for image classification (cifar, imagenet) │   │   ├── imagenet_classes.py # Helper for imagenet class names │   │   ├── plotting.py # Plotting utils specific to this task │   │   └── analysis │   │   ├──run_imagenet_analysis.py # ImageNet eval and visualisation code │   │      └──outputs/ # Folder for outputs of analysis │   ├── mazes │   │   ├── train.py # Training code for solving 2D mazes (by way of a route; see paper) │   │   └── plotting.py # Plotting utils specific to this task │   │   └── analysis │   │   ├──run.py # Maze analysis code │   │      └──outputs/ # Folder for outputs of analysis │   ├── sort │   │   ├── train.py # Training code for sorting │   │   └── utils.py # Sort specific utils (e.g., CTC decode) │   ├── parity │   │   ├── train.py # Training code for parity task │   │   ├── utils.py # Parity-specific helper functions │   │   ├── plotting.py # Plotting utils specific to this task │   │   ├── scripts/ │   │   │   └── *.sh # Training scripts for different experimental setups │   │   └── analysis/ │   │   └── run.py # Entry point for parity analysis │   ├── qamnist │   │   ├── train.py # Training code for QAMNIST task (quantized MNIST) │   │   ├── utils.py # QAMNIST-specific helper functions │   │   ├── plotting.py # Plotting utils specific to this task │   │   ├── scripts/ │   │   │   └── *.sh # Training scripts for different experimental setups │   │   └── analysis/ │   │   └── run.py # Entry point for QAMNIST analysis │   └── rl │      ├── train.py # Training code for RL environments │      ├── utils.py # RL-specific helper functions │      ├── plotting.py # Plotting utils specific to this task │      ├── envs.py # Custom RL environment wrappers │      ├── scripts/ │      │   ├── 4rooms/ │      │   │   └── *.sh # Training scripts for MiniGrid-FourRooms-v0 environment │      │   ├── acrobot/ │      │   │   └── *.sh # Training scripts for Acrobot-v1 environment │      │   └── cartpole/ │      │   └── *.sh # Training scripts for CartPole-v1 environment │      └── analysis/ │      └── run.py # Entry point for RL analysis ├── data # This is where data will be saved and downloaded to │   └── custom_datasets.py # Custom datasets (e.g., Mazes), sort ├── models │   ├── ctm.py # Main model code, used for: image classification, solving mazes, sort │   ├── ctm_*.py # Other model code, standalone adjustments for other tasks │   ├── ff.py # feed-forward (simple) baseline code (e.g., for image classification) │   ├── lstm.py # LSTM baseline code (e.g., for image classification) │   ├── lstm_*.py # Other baseline code, standalone adjustments for other tasks │   ├── modules.py # Helper modules, including Neuron-level models and the Synapse UNET │   ├── utils.py # Helper functions (e.g., synch decay) │   └── resnet.py # Wrapper for ResNet featuriser ├── utils │   ├── housekeeping.py # Helper functions for keeping things neat │   ├── losses.py # Loss functions for various tasks (mostly with reshaping stuff) │   └── schedulers.py # Helper wrappers for learning rate schedulers └── checkpoints    └── imagenet, mazes, ... # Checkpoint directories (see google drive link for files) ``` -------------------------------- ### Train Q&A MNIST CTM Model (10 Iterations) Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/qamnist/README.md Executes a bash script to train the 10-iteration Continuous Thought Machine (CTM) for the Q&A MNIST project. This command should be run from the root directory of the repository to ensure correct path resolution for the script. ```bash bash tasks/qamnist/scripts/train_ctm_10.sh ``` -------------------------------- ### Authenticate HuggingFace CLI Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/image_classification/README.md This command authenticates the user with the Hugging Face backend using a previously generated access token. Successful authentication is crucial for allowing the code to download the ImageNet dataset and proceed with training. ```bash huggingface-cli login ``` -------------------------------- ### Run CTM RL Training for Acrobot Task Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/rl/README.md This bash script initiates the 2-iteration Continuous Thought Machine (CTM) training process specifically for the Acrobot task. It is designed to be executed from the root directory of the repository. ```bash bash tasks/rl/scripts/acrobot/train_ctm_2.sh ``` -------------------------------- ### Run Parity CTM Training Script Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/parity/README.md Executes a bash script to train a Continuous Thought Machine (CTM) for the parity task. This specific command runs a configuration for 75 iterations and a 25 memory length, as used in the paper. The script should be run from the repository's root directory. ```bash bash tasks/parity/scripts/train_ctm_75_25.sh ``` -------------------------------- ### Run Distributed ImageNet Training with PyTorch Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/image_classification/README.md This command initiates distributed training for image classification on the ImageNet dataset using PyTorch's `torchrun`. It configures the training process with specific model parameters, such as `d_model`, `synapse_depth`, and `heads`, along with training configurations like `batch_size`, `lr`, and `training_iterations`. It leverages mixed precision and 8 processes per node for efficient training. ```bash torchrun --standalone --nnodes=1 --nproc_per_node=8 -m tasks.image_classification.train_distributed --d_model 4096 --d_input 1024 --synapse_depth 12 --heads 16 --n_synch_out 150 --n_synch_action 150 --neuron_select_type random --iterations 75 --memory_length 25 --deep_memory --memory_hidden_dims 64 --dropout 0.05 --no-do_normalisation --positional_embedding_type none --backbone_type resnet152-4 --batch_size 60 --batch_size_test 64 --lr 5e-4 --training_iterations 500001 --warmup_steps 10000 --use_scheduler --scheduler_type cosine --weight_decay 0.0 --log_dir logs-lambda/imagenet-distributed-4april/d=4096--i=1024--h=16--ns=150-random--iters=75x25--h=64--drop=0.05--pos=none--back=152x4--seed=42 --dataset imagenet --save_every 2000 --track_every 5000 --seed 42 --n_test_batches 50 --use_amp ``` -------------------------------- ### Run Parity Analysis Script Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/parity/README.md Executes the Python analysis module for the parity task. This command requires specifying the path to the directory containing saved checkpoints via the `--log_dir` argument. Checkpoints can be generated from training or downloaded separately. ```python python -m tasks.parity.analysis.run --log_dir ``` -------------------------------- ### Run RL Analysis with Checkpoints Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/rl/README.md This Python script performs analysis on the results of the RL training. It requires a specified log directory containing saved training checkpoints, which can be generated during training or downloaded separately. ```python python -m tasks.rl.analysis.run --log_dir ``` -------------------------------- ### Run Small Maze Training for Local Iteration Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/mazes/README.md Command to train a Continuous Thought Machine (CTM) locally using the 'mazes-small' dataset. This configuration is optimized for faster iteration and testing, allowing training without a GPU within 12-24 hours. It specifies parameters like dataset, route length, curriculum lookahead, model type, dimensions, and training iterations. ```python python -m tasks.mazes.train --dataset mazes-small --maze_route_length 50 --cirriculum_lookahead 5 --model ctm --d_model 1024 --d_input 256 --backbone_type resnet18-1 --synapse_depth 8 --heads 4 --n_synch_out 128 --n_synch_action 128 --neuron_select_type random-pairing --memory_length 25 --iterations 50 --training_iterations 100001 --lr 1e-4 --batch_size 64 --batch_size_test 32 --n_test_batches 50 --log_dir logs/mazes-small-tester --track_every 2000 ``` -------------------------------- ### Run Full Maze Training Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/mazes/README.md Command to execute the full maze training process as used for the paper. This script trains a Continuous Thought Machine (CTM) model for 2D maze solving, specifying various architectural and training parameters like model dimensions, synapse depth, heads, synchronization units, memory configurations, learning rates, and logging directories. ```python python -m tasks.mazes.train --d_model 2048 --d_input 512 --synapse_depth 4 --heads 8 --n_synch_out 64 --n_synch_action 32 --neuron_select_type first-last --iterations 75 --memory_length 25 --deep_memory --memory_hidden_dims 32 --dropout 0.1 --no-do_normalisation --positional_embedding_type none --backbone_type resnet34-2 --batch_size 64 --batch_size_test 64 --lr 1e-4 --training_iterations 1000001 --warmup_steps 10000 --use_scheduler --scheduler_type cosine --weight_decay 0.0 --log_dir logs/mazes/d=2048--i=512--h=8--ns=64-32--iters=75x25--h=32--drop=0.1--pos=none--back=34-2--seed=42 --dataset mazes-medium --save_every 2000 --track_every 5000 --seed 42 --n_test_batches 50 ``` -------------------------------- ### Execute ImageNet Analysis Script Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tasks/image_classification/analysis/README.md This command runs the Python module responsible for ImageNet classification analysis. It generates various visual outputs like figures, GIFs, and MP4 files. Ensure this command is executed from the project's base directory. ```python python -m tasks.image_classification.analysis.run_imagenet_analysis ``` -------------------------------- ### Execute All Project Tests with Pytest Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tests/README.md This command runs the entire test suite for the `continuous-thought-machines` project. It sets the `PYTHONPATH` to the current directory, allowing Python to locate modules, and then invokes `pytest` on the `tests/tests.py` file to discover and execute all defined tests. ```bash PYTHONPATH=. pytest tests/tests.py ``` -------------------------------- ### Run Specific Golden Test for Model Behavior Source: https://github.com/sakanaai/continuous-thought-machines/blob/main/tests/README.md This command executes a particular 'golden test' to verify if recent code changes have altered the model's expected behavior. The `` placeholder should be replaced with a specific test identifier such as `parity`, `qamnist`, or `rl`, allowing targeted validation of model outputs against predefined expectations. If the model's output differs from the expected golden output, the test will fail. ```bash PYTHONPATH=. pytest tests/tests.py::test_golden_ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.