title: How To Import The MNIST Dataset From Local Directory Using PyTorch
body: <p>I am writing a code of a well-known problem <code>MNIST database of handwritten digits</code> in PyTorch. I downloaded the train and testing dataset (from the main website) including the labeled dataset. The dataset format is <code>t10k-images-idx3-ubyte.gz</code> and after extract <code>t10k-images-idx3-ubyte</code>. My dataset folder looks like</p>
  <pre><code>MINST
   Data
    train-images-idx3-ubyte.gz
    train-labels-idx1-ubyte.gz
    t10k-images-idx3-ubyte.gz
    t10k-labels-idx1-ubyte.gz
  </code></pre>
  <p>Now, I wrote a code to load data like bellow</p>
  <pre><code>def load_dataset():
      data_path = &quot;/home/MNIST/Data/&quot;
      xy_trainPT = torchvision.datasets.ImageFolder(
          root=data_path, transform=torchvision.transforms.ToTensor()
      )
      train_loader = torch.utils.data.DataLoader(
          xy_trainPT, batch_size=64, num_workers=0, shuffle=True
      )
      return train_loader
  </code></pre>
  <p>My code is showing <code>Supported extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif,.tiff,.webp</code></p>
  <p>How can I solve this problem and I also want to check that my images are loaded (just a figure contains the first 5 images) from the dataset?</p>