alameer:

vgg = models.vgg16(pretrained=pretrained)


You have this line under your init method. It doesn’t know where to get vgg16 from.  If you don’t need this (since it looks like you already have VGG defined in the class?) you can just comment it out. Otherwise if you do need it, you need to have this line: import torchvision.models as models to get access to the vgg16 class.