title: How do you load MNIST images into Pytorch DataLoader?
body: <p>The pytorch tutorial for data loading and processing is quite specific to one example, could someone help me with what the function should look like for a more generic simple loading of images?</p>
  
  <p>Tutorial: <a href="http://pytorch.org/tutorials/beginner/data_loading_tutorial.html" rel="noreferrer">http://pytorch.org/tutorials/beginner/data_loading_tutorial.html</a></p>
  
  <p>My Data:</p>
  
  <p>I have the MINST dataset as jpg's in the following folder structure. (I know I can just use the dataset class, but this is purely to see how to load simple images into pytorch without csv's or complex features).</p>
  
  <p>The folder name is the label and the images are 28x28 png's in greyscale, no transformations required.</p>
  
  <pre><code>data
      train
          0
              3.png
              5.png
              13.png
              23.png
              ...
          1
              3.png
              10.png
              11.png
              ...
          2
              4.png
              13.png
              ...
          3
              8.png
              ...
          4
              ...
          5
              ...
          6
              ...
          7
              ...
          8
              ...
          9
              ...
  </code></pre>