Thank you. I fixed the bug. The input was 256*256. Thank you for the response though. In reference to the code, I have another issue which you have addressed Error: Expected more than 1 value per channel when training 11. I do have a batch_size of  1 . In that case, the  BatchNorm2d  is not valid. Then, why I am not getting the errors earlier. Like I am only getting the error  ValueError: Expected more than 1 value per channel when training, got input size [1, 512, 1, 1]  and not when my tensor size is  [1, 64, 128, 128] . [line 199 on the code] Upon putting bn=False, the code runs.