Solved by ptrblck in post #2 
              
              
                Based on the error message it seems the spatial size is different for the loaded tensors, which will raise this error while creating a batch. 
You could add transforms.Resize(size) to the transformation to create tensors with the same spatial size.