title: DataLoader not randomly sampling in PyTorch
body: <p>My DataLoader is returning me the same image with each epoch. My model is only looking at the same single image (indexed '0') each time (batch size is 1...although nothing changes with different batch sizes, anyways).</p>
  
  <p>Here's my dataset, stripped down to the important bits:</p>
  
  <pre><code>class MyDataset(Dataset):
  
      def __init__(self, path, loader=pil_loader):
          self.path = path
          self.images = os.listdir(path)
  
      def __getitem__(self, index):
          image = self.images[index]
  
      . . .
  </code></pre>
  
  <p>And here's the DataSet:</p>
  
  <pre><code>train_ds = MyDataset('/data')
  </code></pre>
  
  <p>And here's my sampler:</p>
  
  <pre><code>train_sampler = RandomSampler(train_ds)
  </code></pre>
  
  <p>And here's my DataLoader:</p>
  
  <pre><code>train_dl = DataLoader(train_ds, batch_size=1, sampler=train_sampler)
  </code></pre>
  
  <p>I'm not sure why it is returning me the same image each time, during 
   training.</p>
  
  <p>Do I have <code>RandomSampler</code> incompletely set up? Or maybe I wrote the <code>__getitem__</code> incorrectly? I can't figure it out.</p>