title: Pytorch: how to make the trainloader use a specific amount of images?
body: <p>Assume I am using the following calls:</p>
  
  <pre><code>trainset = torchvision.datasets.ImageFolder(root="imgs/", transform=transform)
  trainloader = torch.utils.data.DataLoader(trainset,batch_size=4,suffle=True,num_workers=1)
  </code></pre>
  
  <p>As far as I can tell, this defines the trainset as consisting of all the images in the folder "images", with labels as defined by the specific folder location.</p>
  
  <p>My question is - 
  Is there any direct/easy way to define the trainset to be a sub-sample of the images in this folder? For example, define trainset to be a random sample of 10 images from every sub-folder?</p>
  
  <p>Thanks in advance  </p>