@isalirezag  You can find useful notes on (autograd notes 78) & (transfer learning tutorial 163). Be aware, instead of load
models.resnet18(pretrained=True)
you can load another models like alexnet
alexnet = models.alexnet(pretrained=True)
see other models from here (PyTorch Models 87)