當前位置: 首頁>>代碼示例>>Python>>正文


Python models.densenet169方法代碼示例

本文整理匯總了Python中torchvision.models.densenet169方法的典型用法代碼示例。如果您正苦於以下問題:Python models.densenet169方法的具體用法?Python models.densenet169怎麽用?Python models.densenet169使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在torchvision.models的用法示例。


在下文中一共展示了models.densenet169方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: densenet169

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import densenet169 [as 別名]
def densenet169(num_classes=1000, pretrained='imagenet'):
    r"""Densenet-169 model from
    `"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`
    """
    model = models.densenet169(num_classes=num_classes, pretrained=False)
    if pretrained is not None:
        # '.'s are no longer allowed in module names, but pervious _DenseLayer
        # has keys 'norm.1', 'relu.1', 'conv.1', 'norm.2', 'relu.2', 'conv.2'.
        # They are also in the checkpoints in model_urls. This pattern is used
        # to find such keys.
        settings = pretrained_settings['densenet169'][pretrained]
        pattern = re.compile(
            r'^(.*denselayer\d+\.(?:norm|relu|conv))\.((?:[12])\.(?:weight|bias|running_mean|running_var))$')
        state_dict = model_zoo.load_url(settings['url'])
        for key in list(state_dict.keys()):
            res = pattern.match(key)
            if res:
                new_key = res.group(1) + res.group(2)
                state_dict[new_key] = state_dict[key]
                del state_dict[key]
        model.load_state_dict(state_dict)
    model = modify_densenets(model)
    return model 
開發者ID:alexandonian,項目名稱:pretorched-x,代碼行數:25,代碼來源:torchvision_models.py

示例2: Dense161

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import densenet169 [as 別名]
def Dense161(config):
    return models.densenet169(pretrained=True) 
開發者ID:ngessert,項目名稱:isic2019,代碼行數:4,代碼來源:models.py

示例3: dn169

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import densenet169 [as 別名]
def dn169(pre): return children(densenet169(pre))[0] 
開發者ID:alecrubin,項目名稱:pytorch-serverless,代碼行數:3,代碼來源:torch_imports.py

示例4: densenet169

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import densenet169 [as 別名]
def densenet169(num_classes=1000, pretrained='imagenet'):
    r"""Densenet-169 model from
    `"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`
    """
    model = models.densenet169(pretrained=False)
    if pretrained is not None:
        settings = pretrained_settings['densenet169'][pretrained]
        model = load_pretrained(model, num_classes, settings)
    model = modify_densenets(model)
    return model 
開發者ID:Cadene,項目名稱:pretrained-models.pytorch,代碼行數:12,代碼來源:torchvision_models.py

示例5: denseUnet169

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import densenet169 [as 別名]
def denseUnet169(pretrained=False, d_block_type='basic', init_method='normal', **kwargs):
    r"""Densenet-121 model from
    `"Densely Connected Convolutional Networks" <https://arxiv.org/pdf/1608.06993.pdf>`_
    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet
    """
    d_block = get_decoder_block(d_block_type)
    model = DenseUNet(num_init_features=64, growth_rate=32, block_config=(6, 12, 32, 32), d_block=d_block,
                      **kwargs)


    if pretrained:
        w_init.init_weights(model, init_method)
        # Get state dict from the actual model
        model_dict = model.state_dict()
        # pretrained_dict = model_zoo.load_url(model_urls['resnet50'])
        pretrained_dict = models.densenet169(pretrained=True).state_dict()
        pretrained_dict = {k: v for k, v in pretrained_dict.items() if k in model_dict}
        # added to pytorch 0.4
        pattern = re.compile(
            r'^(.*denselayer\d+\.(?:norm|relu|conv))\.((?:[12])\.(?:weight|bias|running_mean|running_var))$')
        # state_dict = model_zoo.load_url(model_urls['densenet121'])
        for key in list(pretrained_dict.keys()):
            res = pattern.match(key)
            if res:
                new_key = res.group(1) + res.group(2)
                pretrained_dict[new_key] = pretrained_dict[key]
                del pretrained_dict[key]

        model_dict.update(pretrained_dict)
        model.load_state_dict(model_dict)
    #     model.load_state_dict(model_zoo.load_url(model_urls['densenet121']))
    return model 
開發者ID:marcelampc,項目名稱:aerial_mtl,代碼行數:35,代碼來源:dense_decoders.py


注:本文中的torchvision.models.densenet169方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。