Hi,
About first error, make sure you have installed latest pytorch and torchvision packages as it has been added to latest build pytorch 1.7 and torchvision 0.8.
About second error, pad works on tensors too, and you don’t need to convert it to pil and convert back to tensor. The error is from to PIL where you should only pass 2d or 3d but you have also included batches.



 887574002:

        x1 = to_pil_image(x1)
        
        x1 = F.pad(x1, [diffx // 2, diffx - diffx // 2,diffy // 2, diffy - diffy // 2])
        
        x1= to_tensor(x1)



Bests