Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: expected device cuda:0 and dtype Byte but got device cuda:0 and dtype Bool #4

Open
Auroraywood opened this issue Nov 4, 2019 · 4 comments

Comments

@Auroraywood
Copy link

Hi!

An error occurs when I run pretrainer.py. Can you give me some advice? Thanks a lot!

Issue summary

prior.fit(zinc, out=netP_path)
/tmp/pip-req-build-58y_cjjl/aten/src/ATen/native/IndexingUtils.h:20: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.
Traceback (most recent call last):

  File "<ipython-input-17-9e97d71a0301>", line 1, in <module>
    prior.fit(zinc, out=netP_path)

  File "/home/tensorflow/DrugEx/model.py", line 422, in fit
    seqs = self.sample(1000)

  File "/home/tensorflow/DrugEx/model.py", line 388, in sample
    is_end = torch.ge(is_end + end_token, 1)

RuntimeError: expected device cuda:0 and dtype Byte but got device cuda:0 and dtype Bool
@XuhanLiu
Copy link
Owner

XuhanLiu commented Nov 4, 2019

I checked this part of code in my own machine (PyTorch = 1.0 or 1.3 stable), but I did not find such a bug. Could you tell me the version of PyTorch?

@Auroraywood
Copy link
Author

Thank you very much! The version of my pytorch is higher and I have alreadly figure the problem out! But now, I have met another error, when I train prior model on the data zinc_corpus.txt, it occurs keyerror when encode, so I modify voc = util.Voc("data/voc.txt") to voc = util.Voc("data/zinc_voc.txt"), then keyerror in encode disappeared, but now decode occurs keyerror again, this time I am confused.

Traceback (most recent call last):
  File "pretrainer.py", line 60, in <module>
    main()
  File "pretrainer.py", line 27, in main
    prior.fit(zinc, out=netP_path)
  File "/home/tensorflow/DrugEx/model.py", line 428, in fit
    smiles, valids = util.check_smiles(seqs, self.voc)
  File "/home/tensorflow/DrugEx/util.py", line 232, in check_smiles
    smile = voc.decode(seq)
  File "/home/tensorflow/DrugEx/util.py", line 94, in decode
    chars.append(self.ix2tk[i])
KeyError: 0

@XuhanLiu
Copy link
Owner

XuhanLiu commented Nov 7, 2019

Thanks for reminding me this bug. It is caused by the duplication of 'EOS' in vocabulary defined in the file of 'voc.txt'. I have modified the 'util.py' and removed the 'EOS' defined in token sequences. If you do not want to regenerate the corpus, you can simply remove 'EOS' in the file of 'voc.txt'

@Auroraywood
Copy link
Author

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants