Solved by ptrblck in post #4 
              
              
                Based on your description, if sounds rather as if you would like to just load images randomly. 
If that’s the case, just swap by Dataset for ImageFolder and the code should work nevertheless.