Comments (10)
OK, you can try to change
to
self.alpha=alpha
.
from spikingjelly.
Thank you very much! Finally, it works :)
Thank you for your time, Dr. Wei
from spikingjelly.
I guess you install SpikingJelly using pip? If so, you can install it from source again.
git clone https://github.com/fangwei123456/spikingjelly.git
cd spikingjelly
python setup.py install
Since the pypi's version has no compiled CUDA extensions like '_C_neuron'.
from spikingjelly.
You said right and thanks.
from spikingjelly.
Hi there, I'm continuing the fangwei123456/Spike-Element-Wise-ResNet#1
I'm sorry for re-opening this issue. I installed the Anaconda and created a new environment. This time there weren't any setup errors.
1. (sew) assel@assel-System-Product-Name:~/Desktop/SEW_2$ git clone https://github.com/fangwei123456/spikingjelly.git
Cloning into 'spikingjelly'...
remote: Enumerating objects: 9828, done.
remote: Counting objects: 100% (1093/1093), done.
remote: Compressing objects: 100% (411/411), done.
remote: Total 9828 (delta 891), reused 787 (delta 680), pack-reused 8735
Receiving objects: 100% (9828/9828), 35.44 MiB | 8.39 MiB/s, done.
Resolving deltas: 100% (6406/6406), done.
2. (sew) assel@assel-System-Product-Name:~/Desktop/SEW_2$ cd spikingjelly/
3. (sew) assel@assel-System-Product-Name:~/Desktop/SEW_2/spikingjelly$ git reset --hard 2958519df84ad77c316c6e6fbfac96fb2e5f59a3
HEAD is now at 2958519 add pub list
4. (sew) assel@assel-System-Product-Name:~/Desktop/SEW_2/spikingjelly$ python setup.py install
CUDA_HOME is None. Install Without CUDA Extension
running install
running bdist_egg
running egg_info
creating spikingjelly.egg-info
writing spikingjelly.egg-info/PKG-INFO
writing dependency_links to spikingjelly.egg-info/dependency_links.txt
......
.....
Using /home/assel/anaconda3/envs/sew/lib/python3.9/site-packages/typing_extensions-4.1.1-py3.9.egg
Searching for six==1.16.0
Best match: six 1.16.0
Processing six-1.16.0-py3.9.egg
six 1.16.0 is already the active version in easy-install.pth
Using /home/assel/anaconda3/envs/sew/lib/python3.9/site-packages/six-1.16.0-py3.9.egg
Finished processing dependencies for spikingjelly==0.0.0.0.4
This time I was able to run setup.py without any errors. However, it still occurs:
(sew) assel@assel-System-Product-Name:~/Desktop/SEW_2/spikingjelly$ python3 test.py
Traceback (most recent call last):
File "/home/assel/Desktop/SEW_2/spikingjelly/test.py", line 40, in <module>
import sew_resnet, spiking_resnet
File "/home/assel/Desktop/SEW_2/spikingjelly/sew_resnet.py", line 4, in <module>
from spikingjelly.cext import neuron as cext_neuron
File "/home/assel/Desktop/SEW_2/spikingjelly/spikingjelly/cext/neuron.py", line 5, in <module>
import _C_neuron
ModuleNotFoundError: No module named '_C_neuron'
I think this version is spikingjelly==0.0.0.0.4. Could you help please to solve this issue? Thank you!
P.S: My goal was to use pre-trained Imagenet weights which were saved via state_dict. That's the reason why I need to have model architecture.
from spikingjelly.
@mountains-high
I find that you install without CUDA: CUDA_HOME is None. Install Without CUDA Extension
.
'_C_neuron' is a CUDA module.
If you do not have CUDA, you can try to use this code https://github.com/fangwei123456/Spike-Element-Wise-ResNet/tree/new_sj and replace the 'cupy' backend to the 'torch' backend:
from spikingjelly.
Another choice is using to this python neuron
from spikingjelly.clock_driven import neuron, layer, surrogate
layer.MultiStepContainer(neuron.IFNode(detach_reset=True, surrogate_function=surrogate.ATan()))
to replace cext_neuron.MultiStepIFNode
. The neuron has no parameter, and I think it will not influence the loading of weights.
from spikingjelly.
Dr. Fang Wei,
Thank you very much for all your help and support.
- The 1st option (changed 'cupy' into 'torch', but I have CUDA) didn't work. Because that gave
File "/home/assel/Desktop/SEW_2/spiking_resnet.py", line 13, in create_msif
return neuron.MultiStepIFNode(detach_reset=True, surrogate_function=surrogate.ATan(), backend='torch')
AttributeError: module 'spikingjelly.clock_driven.neuron' has no attribute 'MultiStepIFNode'
- The 2nd option: I changed all "cext_neuron" into "layer" neurons.
#self.sn1 = cext_neuron.MultiStepIFNode(detach_reset=True)
self.sn1 = layer.MultiStepContainer(neuron.IFNode(detach_reset=True, surrogate_function=surrogate.ATan()))
3.
net = spiking_resnet.spiking_resnet34()
net.load_state_dict(torch.load("spiking_resnet_34_checkpoint_319.pth")['model'])
Output:
loading Net
Traceback (most recent call last):
File "/home/assel/Desktop/SEW_2/spikingjelly/test.py", line 326, in <module>
net_teacher.load_state_dict(torch.load("spiking_resnet_34_checkpoint_319.pth")['model'])
File "/home/assel/anaconda3/envs/sew/lib/python3.9/site-packages/torch-1.10.2-py3.9-linux-x86_64.egg/torch/nn/modules/module.py", line 1482, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for SpikingResNet:
Missing key(s) in state_dict: "sn1.module.surrogate_function.alpha", "layer1.0.sn1.module.surrogate_function.alpha", "layer1.0.sn2.module.surrogate_function.alpha", "layer1.1.sn1.module.surrogate_function.alpha", "layer1.1.sn2.module.surrogate_function.alpha", "layer1.2.sn1.module.surrogate_function.alpha", "layer1.2.sn2.module.surrogate_function.alpha", "layer2.0.sn1.module.surrogate_function.alpha", "layer2.0.sn2.module.surrogate_function.alpha", "layer2.1.sn1.module.surrogate_function.alpha", "layer2.1.sn2.module.surrogate_function.alpha", "layer2.2.sn1.module.surrogate_function.alpha", "layer2.2.sn2.module.surrogate_function.alpha", "layer2.3.sn1.module.surrogate_function.alpha", "layer2.3.sn2.module.surrogate_function.alpha", "layer3.0.sn1.module.surrogate_function.alpha", "layer3.0.sn2.module.surrogate_function.alpha", "layer3.1.sn1.module.surrogate_function.alpha", "layer3.1.sn2.module.surrogate_function.alpha", "layer3.2.sn1.module.surrogate_function.alpha", "layer3.2.sn2.module.surrogate_function.alpha", "layer3.3.sn1.module.surrogate_function.alpha", "layer3.3.sn2.module.surrogate_function.alpha", "layer3.4.sn1.module.surrogate_function.alpha", "layer3.4.sn2.module.surrogate_function.alpha", "layer3.5.sn1.module.surrogate_function.alpha", "layer3.5.sn2.module.surrogate_function.alpha", "layer4.0.sn1.module.surrogate_function.alpha", "layer4.0.sn2.module.surrogate_function.alpha", "layer4.1.sn1.module.surrogate_function.alpha", "layer4.1.sn2.module.surrogate_function.alpha", "layer4.2.sn1.module.surrogate_function.alpha", "layer4.2.sn2.module.surrogate_function.alpha".
I think I cannot use these weights.
Thank you again for your help.
Have a nice day!
from spikingjelly.
RuntimeError: Error(s) in loading state_dict for SpikingResNet: Missing key(s) in state_dict: "sn1.module.surrogate_function.alpha"
It is strange because the surrogate function should not have the learnable parameter:
import torch
from spikingjelly.clock_driven import neuron, layer, surrogate
net = layer.MultiStepContainer(neuron.IFNode(detach_reset=True, surrogate_function=surrogate.ATan()))
print(net.state_dict())
OrderedDict()
from spikingjelly.
In my case when I run above code:
OrderedDict([('module.surrogate_function.alpha', tensor(2.))])
I am using git reset --hard 2958519df84ad77c316c6e6fbfac96fb2e5f59a3
from spikingjelly.
Related Issues (20)
- voltagescaler 中scale是如何工作的? HOT 3
- 关于SNN的搭建以及在灵汐芯片上进行推理的细节疑问 HOT 1
- Feature extraction for Audio visual speech separation HOT 1
- ANN-to-SNN后的网络能否在灵汐芯片上进行推理? HOT 1
- 如何实现抑制和自适应阈值? HOT 5
- 是否遇到过这种问题? HOT 1
- 是否遇到过这种问题? HOT 3
- Adding DVS-Lip to pypi version HOT 2
- Error speech commands dataet [download_url] HOT 2
- 为什么neuron里找不到MultiStepLIFNode神经元?它被移动或者是代替了吗? HOT 2
- The outputs of the same SCNN with different step mode (multi-step and single-step) are different. / 同一SCNN在不同的步进模式下的输出不同。 HOT 1
- module false HOT 9
- 关于IF或LIF神经元膜电位是否会变为负的问题 HOT 1
- BatchNorm1d issue HOT 1
- About the MNIST classification demo HOT 1
- 请教关于STDP训练的问题 HOT 4
- ANN转SNN HOT 2
- Cannot call pre-trained models in spikingjelly.clock_driven.model HOT 4
- ANN2SNN后,查看SNN某一层的输出 HOT 3
- changing the surrogate function and type of spiking neuron for spiking neurons which are available in the converter snn model HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spikingjelly.