Home

Awesome

IDE-FSNN

This is the PyTorch implementation of paper: Training Feedback Spiking Neural Networks by Implicit Differentiation on the Equilibrium State (NeurIPS 2021 Spotlight). arxiv.

Dependencies and Installation

Dataset Preparation

As for MNIST and Fashion-MNIST, the data can be downloaded by torchvision as in the code. The cifar-10 and cifar-100 datasets are avaliable at here. The N-MNIST dataset is avaliable at here.

We use the preprocessing code for N-MNIST from the TSSL-BP repository. We preprocess the data by this code and then place the data in the /data/NMNIST/.

Training

Run as following with some hyperparameters:

python mnist_conv.py --gpu-id 0 --path path_to_data --time_step 30 --leaky 0.99 -c checkpoint_name

python cifar_alexnetf.py --gpu-id 0 --dataset cifar10 --path path_to_data --time_step 30 --leaky 0.99 -c checkpoint_name

As for the IF model, the leaky term could be set as 1, and for the LIF model, the leaky term should be in the range of (0, 1). The default hyperparameters in the code are the same as in the paper.

Testing

Run as following with some hyperparameters:

python cifar_alexnetf.py --gpu-id 0 --dataset cifar10 --path path_to_data --time_step 30 --leaky 0.99 -c checkpoint_name --resume path_to_checkpoint --evaluate

We also provide the example code to calculate the firing rate statistics during evaluation. Run as following:

python get_rate_cifar_alexnetf.py --gpu-id 0 --dataset cifar10 --path path_to_data --time_step 30 --leaky 0.99 --resume path_to_checkpoint

Some pretrained models on CIFAR-10 and CIFAR-100 can be downloaded from google drive.

Results

The results of our method on MNIST, Fashion-MNIST, N-MNIST, CIFAR-10 and CIFAR-100 are:

MNIST

Neuron ModelNetwork StructureTime stepsMeanStdBestNeuronsParams
IF64C5s (F64C5)3099.49%0.04%99.55%13K229K
LIF (leaky=0.95)64C5s (F64C5)3099.53%0.04%99.59%13K229K

Fashion-MNIST

Neuron ModelNetwork StructureTime stepsMeanStdBestNeuronsParams
IF400 (F400)590.04%0.09%90.14%1.2K478K
LIF (leaky=0.95)400 (F400)590.07%0.10%90.25%1.2K478K

N-MNIST

Neuron ModelNetwork StructureTime stepsMeanStdBestNeuronsParams
IF64C5s (F64C5)3099.30%0.04%99.35%21K291K
LIF (leaky=0.95)64C5s (F64C5)3099.42%0.04%99.47%21K291K

CIFAR-10

Neuron ModelNetwork StructureTime stepsMeanStdBestNeuronsParams
IFAlexNet-F3091.73%0.13%91.85%159K3.7M
LIF (leaky=0.99)AlexNet-F3091.74%0.09%91.92%159K3.7M
IFAlexNet-F10092.25%0.27%92.53%159K3.7M
LIF (leaky=0.99)AlexNet-F10092.03%0.07%92.15%159K3.7M
IFCIFARNet-F3091.94%0.14%92.12%232K11.8M
LIF (leaky=0.99)CIFARNet-F3092.08%0.15%92.23%232K11.8M
IFCIFARNet-F10092.33%0.15%92.57%232K11.8M
LIF (leaky=0.99)CIFARNet-F10092.52%0.17%92.82%232K11.8M

CIFAR-100

Neuron ModelNetwork StructureTime stepsMeanStdBestNeuronsParams
IFAlexNet-F10072.02%0.16%72.23%159K5.2M
IFCIFARNet-F3071.56%0.31%72.10%232K14.8M
LIF (leaky=0.99)CIFARNet-F3071.72%0.22%72.03%232K14.8M
IFCIFARNet-F10073.07%0.21%73.43%232K14.8M
LIF (leaky=0.99)CIFARNet-F10072.98%0.13%73.12%232K14.8M

Acknowledgement

The codes for the broyden's method and some utils are modified from the DEQ and MDEQ repositories. The codes for some utils are from the pytorch-classification repository.

Contact

If you have any questions, please contact mingqing_xiao@pku.edu.cn.