fangwei123456 / spikingjelly

SpikingJelly is an open-source deep learning framework for Spiking Neural Network (SNN) based on PyTorch.
https://spikingjelly.readthedocs.io
Other
1.35k stars 239 forks source link

ResNet-34 SNN accuracy is less as compared to ResNet-18 SNN accuracy #262

Open sauravtii opened 2 years ago

sauravtii commented 2 years ago

Hi, I am trying out this code (https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/ann2snn/examples/resnet18_cifar10.py). The only difference is I am using resnet-34 from this file (https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/ann2snn/sample_models/cifar10_resnet.py). I trained it, converted it to SNN and also simulated it. The accuracy that I got after running the resnet-18 architecture was 94.1 % (shown below).

ANN accuracy:
100%|██████████| 200/200 [00:02<00:00, 96.58it/s]
Validating Accuracy: 0.946
Converting...
100%|██████████| 500/500 [00:09<00:00, 52.04it/s]
SNN accuracy:
100%|██████████| 200/200 [05:27<00:00,  1.64s/it]
Validating Accuracy: 0.941

For resnet-34 I am getting the following accuracies after training it for 150 epochs, converting it to SNN and simulating it.

Epoch: 149
100%|██████████| 500/500 [00:07<00:00, 65.69it/s]
Validating Accuracy: 0.965

100%|██████████| 200/200 [00:01<00:00, 106.85it/s]
ANN Validating Accuracy: 0.8307
---------------------------------------------
Converting using MaxNorm
100%|██████████| 500/500 [00:08<00:00, 57.73it/s]
Simulating...
100%|██████████| 200/200 [17:48<00:00,  5.34s/it]
SNN accuracy (simulation 700 time-steps): 0.8248
---------------------------------------------
Converting using RobustNorm
100%|██████████| 500/500 [05:52<00:00,  1.42it/s]
Simulating...
100%|██████████| 200/200 [18:01<00:00,  5.41s/it]
SNN accuracy (simulation 700 time-steps): 0.8073
---------------------------------------------
Converting using 1/2 max(activation) as scales...
100%|██████████| 500/500 [00:08<00:00, 56.58it/s]
Simulating...
100%|██████████| 200/200 [18:03<00:00,  5.42s/it]
SNN accuracy (simulation 700 time-steps): 0.8160

Can anyone please tell me how can I get the same accuracy for resnet-34 and also for other resnet architectures as mentioned here ?

sauravtii commented 2 years ago

Just wanted to follow up.