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 in training scripts #16

Closed DaHaiHuha closed 4 years ago

DaHaiHuha commented 4 years ago

with the default parameters in repo, RuntimeError occurs in train_similarity_and_contact.py

Traceback (most recent call last):
  File "*/.pycharm_helpers/pydev/pydevd.py", line 1415, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "*/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "*/protein-sequence-embedding-iclr2019/train_similarity_and_contact.py", line 587, in <module>
    main()
  File "*/protein-sequence-embedding-iclr2019/train_similarity_and_contact.py", line 508, in main
    for (cmap_x, cmap_y), (scop_x0, scop_x1, scop_y) in zip(cmap_train_iterator, scop_train_iterator):
  File "*/anaconda3/envs/iclr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    index = self._next_index()  # may raise StopIteration
  File "*/anaconda3/envs/iclr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 318, in _next_index
    return next(self._sampler_iter)  # may raise StopIteration
  File "*/anaconda3/envs/iclr/lib/python3.7/site-packages/torch/utils/data/sampler.py", line 200, in __iter__
    for idx in self.sampler:
  File "*/anaconda3/envs/iclr/lib/python3.7/site-packages/torch/utils/data/sampler.py", line 160, in __iter__
    return iter(torch.multinomial(self.weights, self.num_samples, self.replacement).tolist())
RuntimeError: number of categories cannot exceed 2^24

It seems that there's a BUG in WeightedRandomSampler, could be pytorch version's problem, so any ideas for solving this? Or @tbepler could you please provide the version number of the pytorch when you developed it? Thanks!

tbepler commented 4 years ago

This code was originally developed for pytorch 0.4. It should also work with pytorch 1.0. I can't reproduce this bug with pytorch 0.4. What version of pytorch are you using?

DaHaiHuha commented 4 years ago

This code was originally developed for pytorch 0.4. It should also work with pytorch 1.0. I can't reproduce this bug with pytorch 0.4. What version of pytorch are you using?

Thanks for your reply, I'm using the latest pytorch version 1.13. Yes, it works with pytorch 1.0 without this problem.