fangwei123456 / spikingjelly

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

BatchNorm1d tensor size verification bug #493

Closed Thvnvtos closed 9 months ago

Thvnvtos commented 9 months ago

Issue type

SpikingJelly version latest version

Description

Hello, I think there is a bug in: _spikingjelly/activationbased/layer/BatchNorm1d

elif self.step_mode == 'm':
            if x.dim() != 4 or x.dim() != 3:
                raise ValueError(f'expected x with shape [T, N, C, L] or [T, N, C], but got x with shape {x.shape}!')

I think it should be an and instead of or. Because if x.dim is 4 then x.dim() != 3 is true and the error will be raised. Which is not wanted. Here is an example I got: image

fangwei123456 commented 9 months ago

Thanks for bug reporting!