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

bug arises when using 'split_to_train_test_set()' #112

Closed Ikarosy closed 3 years ago

Ikarosy commented 3 years ago

when I use function 'split_to_train_test_set()' like :

dataset = CIFAR10DVS(DVSCIFAR10str, data_type = 'frame', frames_number=steps, split_by = 'number', transform = None, target_transform = None) train_dataset, val_dataset = split_to_train_test_set( train_ratio=0.9, origin_dataset = dataset, num_classes=10, random_split = False )

a bug arises in spikingjelly->datasets->init.py line 441, which is 'for i, x, y in enumerate(origin_dataset):, 3 expected, got 2' I edited the following lines of the 'for' block as: for i, x in enumerate(origin_dataset): if isinstance(x[1], np.ndarray) or isinstance(x[1], torch.Tensor): y = x[1].item() else: y = x[1] label_idx[y].append(i)

from the origin one: for i, x, y in enumerate(origin_dataset): if isinstance(y, np.ndarray) or isinstance(y, torch.Tensor): y = y.item() label_idx[y].append(i)

and the bug seems solved as far as im concerned

hope that would be useful

fangwei123456 commented 3 years ago

Hi, which version of SpikingJelly do you use?

Ikarosy commented 3 years ago

I think it the latest one, 0.0.0.0.6. I just installed spikingjelly yesterday via ‘pip install spikingjelly ‘. The following is the info of the spikingjelly installed:

->pip show spikingjelly Name: spikingjelly Version: 0.0.0.0.6 Summary: A deep learning framework for SNNs built on PyTorch. Home-page: https://github.com/fangwei123456/spikingjelly Author: PKU MLG, PCL, and other contributors Author-email: @., @. License: UNKNOWN Location: /home/yaoxingting/anaconda3/lib/python3.8/site-packages Requires: tqdm, numpy, torch, torchvision, scipy, matplotlib Required-by:

2021年9月22日 下午1:07,fangwei123456 @.***> 写道:

Hi, which version of SpikingJelly do you use?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/fangwei123456/spikingjelly/issues/112#issuecomment-924587970, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ7LIFHQ4HALSWIZ57S6KT3UDFQBDANCNFSM5EQMPBAQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

fangwei123456 commented 3 years ago

I have just tested to run the latest verison, and no error was raised. You can try to install from the latest version:

git clone https://github.com/fangwei123456/spikingjelly.git
cd spikingjelly
python setup.py install
Ikarosy commented 3 years ago

Actually, I’ve fixed the issue and it works well. I think the problem might lie in the python environment because when running ‘for I, x, y in enumerate(organ_dataset):’ I only got 2 returned values, and the sample was indeed in x[0] while the label was in x[1] other than in x and y respectively.

If there would be any one got stuck in the same issue as I did, I hope this closed ‘Issue’ can help. Thanks for your reply.

2021年9月22日 下午2:28,fangwei123456 @.***> 写道:

I have just tested to run the latest verison, and no error was raised. You can try to install from the latest version:

git clone https://github.com/fangwei123456/spikingjelly.git cd spikingjelly python setup.py install — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/fangwei123456/spikingjelly/issues/112#issuecomment-924625295, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ7LIFFTZV6WRROJ5CWOP3LUDFZQ5ANCNFSM5EQMPBAQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Ikarosy commented 2 years ago

Glad to see the bug is fixed in spikingjelly 0.0.0.8