The problem is that your train_set has 0 images.
I’ve figured it out from this part of your error:
RuntimeError: must be strictly positive at /home/soumith/local/builder/wheel/pytorch-src/torch/lib/TH/generic/THTensorMath.c:1473
You can check this by doing:
print(len(train_set))
datasets.ImageFolder will pick up all images from subfolders of dataset_path, but not in the root directory of dataset_path itself. Maybe that’s your mistake?
for example if dataset_path has:
a.png
cat/b.png
dog/c.png

ImageFolder will have length=2 and will have 2 classes ['cat', 'dog'] with indices [0, 1] and will have two images b.png, c.png in it.
It will not have a.png

Also, another thing – ImageFolder will only pick up the following image extensions:

  
      github.com
  
  
    pytorch/vision/blob/master/torchvision/datasets/folder.py#L7-L10 8

IMG_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm']




def is_image_file(filename):



  
  
    
    
  
  



Hope that helps figure out your issue.