You could probably just access the vgg module via: self.model.vgg._modules.
What is your use case that you would need this loop and the conditions? Your model’s forward method should properly execute the computation or do you see any issues?