Skip to content

Instantly share code, notes, and snippets.

@LiamHz
Created January 8, 2019 22:21
Show Gist options
  • Save LiamHz/05aacc355589e4047f6ad4e1e2dddc36 to your computer and use it in GitHub Desktop.
Save LiamHz/05aacc355589e4047f6ad4e1e2dddc36 to your computer and use it in GitHub Desktop.
# Get the "features" portion of VGG19
# The classifier portion is not needed for style transfer
vgg = models.vgg19(pretrained=True).features
# Freeze all VGG parameters
# Since only activations are measured for each conv layer
# Network weights aren't modified
for param in vgg.parameters():
param.requires_grad_(False)
# Move the model to GPU, if available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
vgg.to(device)
print(vgg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment