Last active
June 27, 2021 18:27
-
-
Save J3698/824c2f4e2a6f75c08a4dfde7f0bdbc6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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