hjq310 / text-classification-in-memristorsnn

This Pytorch-based framework demonstrates a sentiment analysis task in the IMDB movie reviews dataset using an SNN with a statistic memristor model
GNU General Public License v3.0
19 stars 1 forks source link

Error on running anntosnn #1

Open bambangkun2021 opened 1 year ago

bambangkun2021 commented 1 year ago

I tried to run the program with only call train.py and there's some error

Traceback (most recent call last): File "/home/ml/Python/text-classification-in-memristorsnn-master/train.py", line 94, in train(seed = args.seed, File "/home/ml/Python/text-classification-in-memristorsnn-master/train.py", line 27, in train anntosnn(N_EPOCHS, SEED, offset, glove_matrix, output_dim, \ File "/home/ml/Python/text-classification-in-memristorsnn-master/anntosnn.py", line 270, in anntosnn snntest(test_dataloader, modelANNtoSNN, criterionSNN) File "/home/ml/Python/text-classification-in-memristorsnn-master/anntosnn.py", line 249, in snntest test_loss, test_acc = evaSNN(modelANNtoSNN, test_dataloader, criterionSNN) File "/home/ml/Python/text-classification-in-memristorsnn-master/anntosnn.py", line 200, in evaSNN predictions = model(text) File "/home/ml/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, *kwargs) File "/home/ml/Python/text-classification-in-memristorsnn-master/anntosnn.py", line 93, in forward self.embedded = self.embedding(text) # [sent len, batch size, emb dim] File "/home/ml/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(input, **kwargs) File "/home/ml/.local/lib/python3.9/site-packages/torch/nn/modules/sparse.py", line 160, in forward return F.embedding( File "/home/ml/.local/lib/python3.9/site-packages/torch/nn/functional.py", line 2210, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)

Is there anything I can change to fix the problem

TseU33 commented 1 week ago

I'm also running into this problem, how did you solve it?