Skip to content

Instantly share code, notes, and snippets.

@fg91
Created March 16, 2019 22:41
Show Gist options
  • Save fg91/3bc3ea7dfa8296fc90aae1cf90e9bda9 to your computer and use it in GitHub Desktop.
Save fg91/3bc3ea7dfa8296fc90aae1cf90e9bda9 to your computer and use it in GitHub Desktop.
model = models.resnet34(pretrained=True).cuda()
# Freeze the base of the network and only train the new custom layers
for param in model.parameters():
param.requires_grad = False
p=0.1
model.fc = nn.Sequential(nn.BatchNorm1d(512),
nn.Dropout(p),
nn.Linear(in_features=512, out_features=512, bias=True),
nn.ReLU(),
nn.BatchNorm1d(512),
nn.Dropout(p),
nn.Linear(in_features=512, out_features=300, bias=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment