msamogh/nonechucks

AttributeError: module 'torch.utils.data' has no attribute 'Sampler'

ChrisPalmerNZ opened this issue · 3 comments

Trying to import nonechucks under Pytorch 0.4 I get an error, is this related to the Pytorch version?

AttributeError                            Traceback (most recent call last)
<ipython-input-3-dc35b3a9e8ee> in <module>()
      2 import torch.utils.data
      3 
----> 4 import nonechucks

/opt/conda/lib/python3.6/site-packages/nonechucks/__init__.py in <module>()
      1 from .dataset import SafeDataset
----> 2 from .sampler import SafeSampler
      3 from .dataloader import SafeDataLoader
      4 
      5 __all__ = ['SafeDataset', 'SafeSampler', 'SafeDataLoader']

/opt/conda/lib/python3.6/site-packages/nonechucks/sampler.py in <module>()
      5 
      6 
----> 7 class SafeSampler(torch.utils.data.Sampler):
      8     """SafeSampler can be used both as a standard Sampler (over a Dataset),
      9     or as a wrapper around an existing `Sampler` instance. It allows you to

AttributeError: module 'torch.utils.data' has no attribute 'Sampler'

Yes, it's to do with the version. PyTorch 0.4 is currently not supported. Is there any reason you cannot upgrade to a later version?

I've fixed this particular issue with c9f0409, but I'm yet to look into the full range of changes from PyTorch 0.4 to 0.4.1. If you face any other issues, please report your issues. Thanks!

Thanks @msamogh - I am currently doing a course with Udacity and they are still back on 0.4.0 - but apart from that I use 1.0...