-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jxu7
committed
Jun 3, 2017
1 parent
12d2561
commit d10fd53
Showing
5 changed files
with
53 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import torch.utils.model_zoo as model_zoo | ||
from torchvision.models.densenet import model_urls | ||
from torchvision.models import DenseNet | ||
|
||
|
||
def densenet121(num_classes=17, pretrained=False): | ||
model = DenseNet(num_init_features=64, growth_rate=32, block_config=(6, 12, 24, 16), num_classes=num_classes) | ||
if pretrained: | ||
# load model dictionary | ||
model_dict = model.state_dict() | ||
# load pretrained model | ||
pretrained_dict = model_zoo.load_url(model_urls['densenet121']) | ||
# update model dictionary using pretrained model without classifier layer | ||
model_dict.update({key: pretrained_dict[key] for key in pretrained_dict.keys() if 'classifier' not in key}) | ||
model.load_state_dict(model_dict) | ||
return model | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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