This code looks fine to me. If I were you, I’d train a bit longer (5 epochs is not that much for a resnet50; try it with 50 or something like that) and maybe choose a smaller network (I’d say a resnet18 should be more than sufficient here)