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

About layer.MultiDimensionalAttention and layer.TemporalWiseAttention #354

Closed masac11 closed 1 year ago

masac11 commented 1 year ago

SpikingJelly version 0.0.0.0.14

path:spikingjelly/activation_based/layer.py MultiDimensionalAttention and TemporalWiseAttention I think these two methods should inherit nn.Module, so that we can directly call it like this

e = nn.Sequential(
    layer.Conv2d(),
    layer.TemporalWiseAttention()
   )
e(x)

If not, I don't know how to call

fangwei123456 commented 1 year ago

Hi, this moduel is inherited from MultiStepModule because it only supports input with a shape [T, N, *].

https://github.com/fangwei123456/spikingjelly/blob/5a3aecfbfb9b048c9bc7c8d9af022c98822b380b/spikingjelly/activation_based/layer.py#L1934

Please refer to this tutorial for more information about the step mode:

https://spikingjelly.readthedocs.io/zh_CN/latest/activation_based_en/basic_concept.html

fangwei123456 commented 1 year ago

Hi, some bugs of these modules were found. https://github.com/fangwei123456/spikingjelly/commit/edb36cc18829e4bfcfc580df318d54cd07212d89

If you codes do not work, you can install the latest SJ from the GitHub and try again.