conv_snn icon indicating copy to clipboard operation
conv_snn copied to clipboard

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Open meltingCat opened this issue 3 years ago • 4 comments

Got an error in Training & Testing

(conv_snn) test@test-dual1060:~/Desktop/project/conv_snn/CIFAR10-DVS$ python3 main.py
device cuda
  0%|                                                                                                      | 0/1750 [00:00<?, ?it/s]
==> Build model and setup loss and optimizer
==> Epoch:[0/500][training stage]
  0%|                                                                                                      | 0/1750 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "main.py", line 231, in <module>
    main()
  File "main.py", line 65, in main
    model.run()
  File "main.py", line 124, in run
    self.train_1epoch()
  File "main.py", line 172, in train_1epoch
    prec1, prec5 = accuracy(output.data, label.cuda(), topk=(1, 5))
  File "/home/test/Desktop/project/conv_snn/CIFAR10-DVS/utils.py", line 30, in accuracy
    correct_k = correct[:k].view(-1).float().sum(0)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

meltingCat avatar Mar 03 '21 07:03 meltingCat

what is the dataset?! what are the shapes?! is this the default dataset?! please also provide the pytorch version.

aa-samad avatar Mar 03 '21 07:03 aa-samad

thanks for reply so fast. Training dvs-cifar10 and all settings were default, just following the readme.

pytorch version is 1.7.1

meltingCat avatar Mar 03 '21 07:03 meltingCat

I add contiguous() to line30 in conv_snn/CIFAR10-DVS/utils.py/ and start to train correct_k = correct[:k].contiguous().view(-1).float().sum(0)

but got another error FileNotFoundError: [Errno 2] No such file or directory: 'record/spatial/rgb_train.csv'

meltingCat avatar Mar 03 '21 08:03 meltingCat

it is my job ;) well it appears there is a difference in view function of newer pytorch versions, the second problem is odd!! ok, i don't have access to my laptop now, it will take approx 12 hours to check this. I will inform you about the problem and the possible fix.

aa-samad avatar Mar 03 '21 08:03 aa-samad