tbepler / protein-sequence-embedding-iclr2019

Source code for "Learning protein sequence embeddings using information from structure" - ICLR 2019
Other
253 stars 75 forks source link

RuntimeError: expected type torch.FloatTensor but got torch.LongTensor (run on CPU) #8

Closed 0xooo2A closed 5 years ago

0xooo2A commented 5 years ago

I got a type error when I run this project on CPU with commond:

python .\eval_similarity.py .\model\ssa_L1_100d_lstm3x512_lm_i512_mb64_tau0.5_lambda0.1_p0.05_epoch100.sav

Trace back detail shows as followings:

Traceback (most recent call last): File ".\eval_similarity.py", line 261, in main() File ".\eval_similarity.py", line 231, in main scores = score_pairs(model, x0_train, x1_train, batch_size) File ".\eval_similarity.py", line 159, in score_pairs scores.append(model(x0_mb, x1_mb)) File ".\eval_similarity.py", line 93, in call scores[i] = torch.sum(p*levels).item() RuntimeError: expected type torch.FloatTensor but got torch.LongTensor

I also tried eval_secstr.py, got a similar issue:

python .\eval_secstr.py .\model\ssa_L1_100d_lstm3x512_lm_i512_mb64_tau0.5_lambda0.1_p0.05_epoch100.sav

split epoch loss perplexity accuracy Traceback (most recent call last): File ".\eval_secstr.py", line 426, in main() File ".\eval_secstr.py", line 297, in main fit_nn_potentials(model, x_train, y_train, num_epochs=num_epochs, use_cuda=use_cuda) File ".\eval_secstr.py", line 177, in fit_nn_potentials for x,y in iterator: File ".\eval_secstr.py", line 146, in iter x = self.x[order] RuntimeError: tensors used as indices must be long or byte tensors

Runtime: Windows 10, Python 3.

tbepler commented 5 years ago

I suspect these errors are due to changes to automatic type casting in newer versions of pytorch. I just pushed an update that should fix this.

0xooo2A commented 5 years ago

I suspect these errors are due to changes to automatic type casting in newer versions of pytorch. I just pushed an update that should fix this.

I'm using Pytorch 1.0.1, and your fix works for me. Many tanks!