Skip to content

Instantly share code, notes, and snippets.

@KushajveerSingh
Created May 5, 2019 13:59
Show Gist options
  • Save KushajveerSingh/00a676b93cc31b0394db8548bcd7f2aa to your computer and use it in GitHub Desktop.
Save KushajveerSingh/00a676b93cc31b0394db8548bcd7f2aa to your computer and use it in GitHub Desktop.
Load VGG model and pytorch essentials
if torch.cuda.is_available():
device = torch.device('cuda')
else:
raise Exception('GPU is not available')
# Load VGG19 features. We do not need the last linear layers,
# only CNN layers are needed
vgg = vgg19(pretrained=True).features
vgg = vgg.to(device)
# We don't want to train VGG
for param in vgg.parameters():
param.requires_grad_(False)
torch.backends.cudnn.benchmark = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment