title: NotImplementedError: when i try to create a DataLoader object in Pytorch
body: <p>I created a custom Dataset class that inherits from PyTorch's Dataset class, in order to handle my custom dataset which i already preprocessed.  </p>
  
  <p>When i try to create a DataLoader object, i get this error:</p>
  
  <pre><code>/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __init__(self, dataset, batch_size, shuffle, sampler, batch_sampler, num_workers, collate_fn, pin_memory, drop_last, timeout, worker_init_fn)
      174             if sampler is None:
      175                 if shuffle:
  --&gt; 176                     sampler = RandomSampler(dataset)
      177                 else:
      178                     sampler = SequentialSampler(dataset)
  
  /usr/local/lib/python3.6/dist-packages/torch/utils/data/sampler.py in __init__(self, data_source, replacement, num_samples)
       62                              "since a random permute will be performed.")
       63 
  ---&gt; 64         if not isinstance(self.num_samples, int) or self.num_samples &lt;= 0:
       65             raise ValueError("num_samples should be a positive integer "
       66                              "value, but got num_samples={}".format(self.num_samples))
  
  /usr/local/lib/python3.6/dist-packages/torch/utils/data/sampler.py in num_samples(self)
       70         # dataset size might change at runtime
       71         if self._num_samples is None:
  ---&gt; 72             return len(self.data_source)
       73         return self._num_samples
       74 
  
  /usr/local/lib/python3.6/dist-packages/torch/utils/data/dataset.py in __len__(self)
       18 
       19     def __len__(self):
  ---&gt; 20         raise NotImplementedError
       21 
       22     def __add__(self, other):
  
  NotImplementedError: 
  
  </code></pre>
  
  <p>So, the error message regards to the not implementation of the <strong>len</strong>() function in the dataset.py, right?  But i did implement it and the <strong>getitem</strong>(), <strong>init</strong>() as well .</p>
  
  <p>How can i overcome this? 
  Thank you</p>