Solved by ptrblck in post #6 
              
              
                Even though you are defining a valid Resize transformation, you are not applying the transformation in your CustomDataset, but instead but use ToTensor(). 
If your images have different spatial size, this shape mismatch error will be raised.