fangwei123456 / spikingjelly

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

ANN2SNN后,查看SNN某一层的输出 #483

Open Steven0007 opened 6 months ago

Steven0007 commented 6 months ago

Read before creating a new issue

For faster response @DingJianhao @fangwei123456

Issue type

Description 您好呀,想问一下,使用demo中的cnn_mnist,使用如下代码查看某一层的输出: image

报错结果: 1704269031275 我看到IFNode类的定义中是有surrogate_function属性的 我该怎么查看某一层的输出,以及转换后的权重?如果可以帮忙解决,将感激不尽!!! Minimal code to reproduce the error/bug

import spikingjelly
# ...
fangwei123456 commented 6 months ago

@Lyu6PosHao

Lyu6PosHao commented 6 months ago

你好,我看报错信息,是snn_output=snn_model(test_image)报错,也就是前向传播就报错了。但我运行了一下cnn_mnist.py的代码,是没有问题的。

查看转换后的权重,直接print(snn_model)就行,结果如下图所示: 1704434059820 因为卷积层、全连接层的weight、bias都和原ANN一致,所以只关注snn tailor(即VoltageScaler)的权重就行。

查看某一层的输出,可以用hook,具体可以看spikingjelly的文档教程;或者自己写一个hook,看VoltageScaler的输出就行。

如果遇到什么问题,再沟通~~

Steven0007 commented 6 months ago

好的,谢谢你,我先试试!