Official code repository for the paper "Weight transport through spike timing for robust local gradients", Gierlich et al., 2025
This repository contains the python code to reproduce the results in the paper (Link).
- Clone the repo (
git clone https://github.com/unibe-cns/sal-code.git
orgit clone [email protected]:unibe-cns/sal-code.git
) or create your own fork if you want to contribute to the project. - Setup you local python environment using you favorite tool:
- The code is tested for python versions >= 3.11 only.
- Using
venv
:python -m venv --system-site-packages <name_of_env>
and activate it:source ./<name_of_env>/bin/activate
- Or using
conda
:conda create -n <name_of_env>
(it's recommended to add the python version: python=3.X) and activate it:conda activate <name_of_env>
- Go to the repo
cd sal-code
and install the dependencies:python -m pip install -r requirements.txt
- Register the ipykernel with
python -m ipykernel install --user --name sal
(5. Install the git pre-commit-hooks:pre-commit install.
This step is recommended if you want to contribute to the project). - Install the pip package for the STDD-calculator:
cd stdd_calculator
and thenpython -m pip install -e .
. This installs the packagestddc
. - Install the pip package for the spiking sampling network:
cd ../spiking_sampling_network
and thenpython -m pip install -e .
. This installs the packageneuralsampling
. - Install the pip package for the spiking microcircuits:
cd ../spiking_microcircuits
and thenpyhton -m pip install -e .
. This installs the packagemicrocircuits
.
The scripts for executing the experiments are located in ´scripts´.
- The spike-timing difference distributions (fig. 2c) are generated by the jupyter notebook
scripts/stdd.ipynb
. - The weight evolution of the two neuron system (fig. 2d) and the phase plane diagram (fig. 2e) is generated by the jupyter notebook
scripts/ppd.ipynb
.
A minimal working example for a simulation of a spiking sampling network is provided by scripts/ssn/train_bm.py
and the corresponding parameter file minimnal_example.yaml
. It can be executed by python train_bm.py minimal_example.yaml
.
To reproduce the raw data for figure 4 and five, the scripts and directories in scripts/ssn
are available. A single simulation can be executed on a single CPU core and typically takes one to two hours. For each of the four experiment types (i.e. synaptic noise and plasticity noise scenario each with and without SAL), a total of 120 independent runs are required. We therefore recommend the simulations to be run in parallel on a HPC cluster. The raw data is then saved in the folder results
.
Each subdirectory of scripts/ssn/
contains a exp.yaml
parameter file and a change_params.py
python script.
- Execute
python change_params.py
to produce the parameter files for the parameter sweep acros different seeds and noise strengths. - Then run
bash launcher.sh
to start the simulations. It is recommended to start this through slurm with 120 parallel tasks. - The raw data can be plotted with
scripts/ssn/plot_fig.ipynb
.
A minimal working example for a simulation of a spiking microcircuits student teacher network is provided by scripts/microcircuits/run.py
and the corresponding parameter file example.yaml
. It can be executed by python run.py example.yaml 0
.
To repoduce the raw data for figure 6, follow the same steps as for the sampling networks.
In each subdirectory of scripts/microcircuits
, do
python change_params.py
to produce the parameter files for the 20 runs with different seeds.- Launch the runs with
bash launcher.sh
. The raw data is stored inresults/microcircuits
The raw data can be plotted with scripts/microcircuits/plot_fig.ipynb
.
The data for figure 7 can be reproached by scripts/psp_shapes.ipynb
. Note that this notebook typically requires a lot of memory.
Figure 8 can be reproduced by scripts/plots_for_proof.ipynb
.