You can get rid of the warning if you match the target size to the output of the model exactly, or vice versa. I think the issue might actually be triggered in the valid_loader loop, as no unsqueeze is done there.