fangwei123456 / spikingjelly

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

TypeError: __init__() got an unexpected keyword argument 'device' #257

Closed sauravtii closed 2 years ago

sauravtii commented 2 years ago

I am trying out this python script (https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/ann2snn/examples/resnet18_cifar10.py). After calling the main function I am getting the follwoing error.

Downloading SJ-cifar10-resnet18_model-sample.pth
Files already downloaded and verified
Files already downloaded and verified
ANN accuracy:
100%|██████████| 200/200 [00:02<00:00, 98.44it/s]
Validating Accuracy: 0.946
Converting...

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [17], in <cell line: 1>()
      2 print('Downloading SJ-cifar10-resnet18_model-sample.pth')
      3 ann2snn.download_url("https://ndownloader.figshare.com/files/26676110",'./SJ-cifar10-resnet18_model-sample.pth')
----> 4 main()

Input In [16], in main()
     63 val(model, device, test_data_loader)
     64 print('Converting...')
---> 65 model_converter = ann2snn.Converter(device=device,mode='Max', dataloader=train_data_loader)
     66 snn_model = model_converter(model)
     67 print('SNN accuracy:')

TypeError: __init__() got an unexpected keyword argument 'device'
fangwei123456 commented 2 years ago

I just fix this bug. Try to use git pull to update SJ.

sauravtii commented 2 years ago

It worked and I got the following output. Is the SNN (spiking neural network) accuracy 94.1 % ? Because it didn't mention anything in front of "SNN accuracy".

Downloading SJ-cifar10-resnet18_model-sample.pth
Files already downloaded and verified
Files already downloaded and verified
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
fangwei123456 commented 2 years ago

Is the SNN (spiking neural network) accuracy 94.1 % ?

Yes.

SNN accuracy:
100%|██████████| 200/200 [05:27<00:00,  1.64s/it]
Validating Accuracy: 0.941
sauravtii commented 2 years ago

Okay, thank you : ) I also wanted to try out other ResNet architectures like Resnet34, resnet50 and resnet 101. Could you please tell me how I can do that ? Do I need to just modify this script (https://github.com/fangwei123456/spikingjelly/blob/master/spikingjelly/activation_based/ann2snn/examples/resnet18_cifar10.py) from resnet18 to the required resnet architecture ?

fangwei123456 commented 2 years ago

Yes, you can modify resnet18_cifar10.py to get other networks.

sauravtii commented 2 years ago

Okay, thanks!