title: IndexError when iterating my dataset using Dataloader in PyTorch
body: <p>I iterated my dataset using Dataloader in PyTorch 0.2 like these:</p>
  
  <pre><code>dataloader = torch.utils.data.DataLoader(...)
  data_iter = iter(dataloader)
  data = data_iter.next()
  </code></pre>
  
  <p>but IndexError was raised.</p>
  
  <pre><code>Traceback (most recent call last):
    File "main.py", line 193, in &lt;module&gt;
      data_target = data_target_iter.next()
    File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 201, in __next__
      return self._process_next_batch(batch)
    File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 221, in _process_next_batch
      raise batch.exc_type(batch.exc_msg)
  IndexError: Traceback (most recent call last):
    File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 40, in _worker_loop
      samples = collate_fn([dataset[i] for i in batch_indices])
    File "/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py", line 40, in &lt;listcomp&gt;
      samples = collate_fn([dataset[i] for i in batch_indices])
    File "/home/asr4/zhuminxian/adversarial/code/dataset/data_loader.py", line 33, in __getitem__
      return self.X_train[idx], self.y_train[idx]
  IndexError: index 4196 is out of bounds for axis 0 with size 4135
  </code></pre>
  
  <p>I am wondering why the index was out of bounds. Is it the bug of Pytorch?</p>
  
  <p>I tried to run my code again, the same error raised, but at different iteration and with different out-of-bound index.</p>