Skip to content

Instantly share code, notes, and snippets.

@J3698
Last active June 27, 2021 18:27
Show Gist options
  • Save J3698/824c2f4e2a6f75c08a4dfde7f0bdbc6d to your computer and use it in GitHub Desktop.
Save J3698/824c2f4e2a6f75c08a4dfde7f0bdbc6d to your computer and use it in GitHub Desktop.
def extract_vgg19_pretrained_layers(self):
# get pretrained model
features = torchvision.models.vgg19_bn(pretrained=True, progress=True).features
# change to reflection
for i in features:
if isinstance(i, nn.Conv2d):
i.padding_mode = 'reflect'
# get blocks of layers we want
feats1 = features[0:3]
feats2 = features[3:10]
feats3 = features[10:17]
feats4 = features[17:30]
return feats1, feats2, feats3, feats4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment