# Run locally The `experiments/` folder of the [ChronoProp repository](https://github.com/Poirazi-Lab/chronoprop) has one Python script per figure. Each script trains that figure's networks from scratch with the paper's settings. To redraw the figures without training, use [Reproduce figures](reproduce.md); a laptop is enough there. ## Requirements - An NVIDIA GPU with 11 GB of memory or more. The paper trained on 12 GB slices of H100 GPUs, and every script also runs on an 11 GB GeForce RTX 2080 Ti. A CPU runs the scripts too, but too slowly for full runs. - Python 3.10 or newer. `pip install -e .` (below) installs PyTorch, NumPy, SciPy, h5py, scikit-learn and matplotlib. The Fig. 2 scripts also need torchvision, which `pip install -e ".[images]"` adds. - From minutes to about 4 hours of GPU time per network (see [Run times](#run-times)). The scripts cover all of the paper's runs on SHD, MNIST and Fashion-MNIST, but not those on SSC. Each dataset downloads the first time it is used. ## Quick test ```bash git clone https://github.com/Poirazi-Lab/chronoprop && cd chronoprop pip install -e . python experiments/fig3_temporal.py --arch rec --timestep coarse --seeds 1234 --epochs 2 --out runs/test python experiments/summarize.py runs/test ``` This trains one recurrent network per method for 2 epochs, in a few minutes, most of them spent downloading SHD. Each epoch prints its loss, accuracies and duration. `summarize.py` then prints, for every condition, the test accuracy at the epoch of best validation accuracy (mean ± s.d. over seeds) next to the paper's value, which 2 epochs are far from reaching. The test writes to its own folder, `runs/test`, so it never mixes with full runs. ## Scripts | Script | Figure | What it trains | |---|---|---| | `fig2_images.py` | Fig. 2 | ChronoProp and BPTT on MNIST or Fashion-MNIST, Δt = 1, 0.5 or 0.1 ms | | `fig2_cost.py` | Fig. 2c–f | the networks whose time, memory, operations and firing are measured, from 50 to 2,000 steps per image | | `fig3_temporal.py` | Fig. 3 | temporal ChronoProp and BPTT on SHD, feedforward or recurrent, Δt = 1 or 0.1 ms | | `fig4a_adaptive.py` | Fig. 4 | the same with adaptive neurons | | `fig4b_dendritic.py` | Supp. Fig. 7 | the same with two-compartment neurons on addSHD | | `fig5_grid.py` | Figs. 5 and 6 | the network of Fig. 5 at any width and recurrent density, and Fig. 6's two BPTT networks | | `fig6_defects.py` | Fig. 6 | training with a hardware defect (HIL), or testing trained networks at every defect level (PTP) | ## Full figure runs These commands train every network of a figure with the paper's seeds and epochs. ```bash # Fig. 2 python experiments/fig2_images.py --dataset mnist fmnist --timestep 1.0 0.5 0.1 # Fig. 2c-f; then add --summary to print the cost table python experiments/fig2_cost.py # Fig. 3, Fig. 4 and Supp. Fig. 7 python experiments/fig3_temporal.py --arch ff rec --timestep coarse fine python experiments/fig4a_adaptive.py --arch ff rec --timestep coarse fine python experiments/fig4b_dendritic.py --arch ff rec --timestep coarse fine # Fig. 5, and the two BPTT networks of Fig. 6 python experiments/fig5_grid.py --hidden 128 256 512 --density 0 0.25 0.5 0.75 1 python experiments/fig5_grid.py --arm bptt bptt_star # Fig. 6, training with each defect (HIL) python experiments/fig6_defects.py train --arm chronoprop bptt bptt_star --defect membrane_noise --level 0.3 0.5 0.75 1 1.5 2 2.5 3 python experiments/fig6_defects.py train --arm chronoprop bptt bptt_star --defect weight_noise --level 0.03 0.05 0.07 0.1 0.15 0.2 0.3 python experiments/fig6_defects.py train --arm chronoprop bptt bptt_star --defect weight_bits --level 2 3 4 5 6 7 8 python experiments/fig6_defects.py train --arm chronoprop bptt bptt_star --defect tau_mismatch --level 0.025 0.05 0.1 0.15 0.2 0.25 0.3 # Supp. Fig. 10, the defect-free networks tested at each defect (PTP), one command per defect python experiments/fig6_defects.py ptp --arm chronoprop bptt bptt_star --defect membrane_noise ``` Then `python experiments/summarize.py runs/
` compares the results with the paper's (`runs/fig2`, `runs/fig3`, `runs/fig4`, `runs/fig4b`, `runs/fig5`, `runs/fig6`). For Fig. 6, the paper's number is the test at the defect that each run prints at its end (`retest` in its `results.pkl`), as a percentage of the defect-free network's accuracy. PTP tests the paper's released networks, which it downloads, or your own with `--checkpoint`, and writes `runs/fig6/ptp__.json`. ## Options Options choose what to train; everything else, from the network to the training schedule, is the paper's setting. An option given several values runs every combination, so `--arch ff rec --timestep coarse fine` trains all four conditions of Fig. 3. `python experiments/