putshua / SNN_conversion_QCFS

47 stars 16 forks source link

Not able to reproduce the same conversion error as reported in the paper. #7

Closed Ikarosy closed 1 year ago

Ikarosy commented 1 year ago

Hi, I tried to reproduce the experiments on CIFAR10 with VGG16. I used the following python commands to train the models:

CUDA_VISIBLE_DEVICES=[gpu id] nohup python main.py train --bs=128 --model=vgg16 --data=cifar10 --id=vgg16_cifar10_bs128_e150_l[x] --l[x] --lr=0.1 > testvgg_cifar10_lx.log 2>&1 &

where [x] is set 2,4,8,16,32,and 64 for six runs. I tested the converted SNNs with following python commands:

CUDA_VISIBLE_DEVICES=[gpu id] python main.py test --bs=128 --model=vgg16 --data=cifar10 --mode=snn --id=vgg16_cifar10_bs128_e150_l[x] --t=[x] --l=[x]
and the results are: t == l ann snn
2 88.17 85.66
4 90.74 86.15
8 92.94 90.46
16 94.47 93.50
32 94.85 94.65
64 94.98 94.93

For SNNs, I report the last value of the printed Accuracy tensor. For example,

CUDA_VISIBLE_DEVICES=1 python main.py test --bs=128 --model=vgg16 --data=cifar10 --mode=snn --id=vgg16_cifar10_bs128_e150_l2 --t=2 --l=2
Files already downloaded and verified
Files already downloaded and verified
100%|█████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:07<00:00,  9.95it/s]
Accuracy:  tensor([0.8300, 0.8566], device='cuda:0')

I report the 0.8566 of the Accuracy: tensor([0.8300, 0.8566], device='cuda:0')

The results are acceptable but not as remarkable as what is reported in your paper. For example, there is only ~0.1% conversion loss if t==16, and SNN performs even better than Ann if t==32 in your paper. So I wonder how to perfectly reproduce your paper's conversion errors. Did I misunderstand your paper or improperly use the codes? Please help.

putshua commented 1 year ago

Try to set training epoch to 300.

putshua commented 1 year ago

Pretrained model updated.

putshua commented 1 year ago

I have updated a new version in a new repo at https://github.com/putshua/ANN_SNN_QCFS. The biggest unreproducable bug is fixed. Compatible with old version. Please switch to the new version.