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


Python resnet.resnet101方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from torchvision.models import resnet [as 別名]
# 或者: from torchvision.models.resnet import resnet101 [as 別名]
def __init__(self, pretrained=True, input_channels=3):
        model = resnet.resnet101(pretrained=pretrained)
        super().__init__(
            model=model,
            input_channels=input_channels) 
開發者ID:PavelOstyakov,項目名稱:pipeline,代碼行數:7,代碼來源:resnet.py

示例2: convert_deferred_batch_norm

# 需要導入模塊: from torchvision.models import resnet [as 別名]
# 或者: from torchvision.models.resnet import resnet101 [as 別名]
def convert_deferred_batch_norm(cls, module: TModule, chunks: int = 1) -> TModule:
        """Converts a :class:`nn.BatchNorm` or underlying
        :class:`nn.BatchNorm`s into :class:`DeferredBatchNorm`::

            from torchvision.models.resnet import resnet101
            from torchgpipe.batchnorm import DeferredBatchNorm
            model = resnet101()
            model = DeferredBatchNorm.convert_deferred_batch_norm(model)

        """
        if isinstance(module, DeferredBatchNorm) and module.chunks is chunks:
            return cast(TModule, module)

        module_output: nn.Module = module

        if isinstance(module, _BatchNorm) and module.track_running_stats:
            module_output = DeferredBatchNorm(module.num_features,
                                              module.eps,
                                              module.momentum,
                                              module.affine,
                                              chunks)
            if module.affine:
                module_output.register_parameter('weight', module.weight)
                module_output.register_parameter('bias', module.bias)
            module_output.register_buffer('running_mean', module.running_mean)
            module_output.register_buffer('running_var', module.running_var)
            module_output.register_buffer('num_batches_tracked', module.num_batches_tracked)

        for name, child in module.named_children():
            module_output.add_module(name, cls.convert_deferred_batch_norm(child, chunks))

        return cast(TModule, module_output) 
開發者ID:kakaobrain,項目名稱:torchgpipe,代碼行數:34,代碼來源:batchnorm.py

示例3: load_resnet

# 需要導入模塊: from torchvision.models import resnet [as 別名]
# 或者: from torchvision.models.resnet import resnet101 [as 別名]
def load_resnet():
    model = resnet101(pretrained=True)
    del model.layer4
    del model.avgpool
    del model.fc
    return model 
開發者ID:rowanz,項目名稱:neural-motifs,代碼行數:8,代碼來源:object_detector.py

示例4: get

# 需要導入模塊: from torchvision.models import resnet [as 別名]
# 或者: from torchvision.models.resnet import resnet101 [as 別名]
def get(cls, args):
        model = ResNet3D(Bottleneck3D, [3, 8, 36, 3])  # 101
        if args.pretrained:
            from torchvision.models.resnet import resnet101
            model2d = resnet101(pretrained=True)
            model.load_2d(model2d)
        return model 
開發者ID:gsig,項目名稱:PyVideoResearch,代碼行數:9,代碼來源:resnet101_3d.py

示例5: create_model

# 需要導入模塊: from torchvision.models import resnet [as 別名]
# 或者: from torchvision.models.resnet import resnet101 [as 別名]
def create_model(model_name, num_classes=1000, pretrained=False, **kwargs):
    if 'test_time_pool' in kwargs:
        test_time_pool = kwargs.pop('test_time_pool')
    else:
        test_time_pool = True
    if model_name == 'dpn68':
        model = dpn68(
            pretrained=pretrained, test_time_pool=test_time_pool, num_classes=num_classes)
    elif model_name == 'dpn68b':
        model = dpn68b(
            pretrained=pretrained, test_time_pool=test_time_pool, num_classes=num_classes)
    elif model_name == 'dpn92':
        model = dpn92(
            pretrained=pretrained, test_time_pool=test_time_pool, num_classes=num_classes)
    elif model_name == 'dpn98':
        model = dpn98(
            pretrained=pretrained, test_time_pool=test_time_pool, num_classes=num_classes)
    elif model_name == 'dpn131':
        model = dpn131(
            pretrained=pretrained, test_time_pool=test_time_pool, num_classes=num_classes)
    elif model_name == 'dpn107':
        model = dpn107(
            pretrained=pretrained, test_time_pool=test_time_pool, num_classes=num_classes)
    elif model_name == 'resnet18':
        model = resnet18(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'resnet34':
        model = resnet34(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'resnet50':
        model = resnet50(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'resnet101':
        model = resnet101(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'resnet152':
        model = resnet152(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'densenet121':
        model = densenet121(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'densenet161':
        model = densenet161(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'densenet169':
        model = densenet169(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'densenet201':
        model = densenet201(pretrained=pretrained, num_classes=num_classes, **kwargs)
    elif model_name == 'inception_v3':
        model = inception_v3(
            pretrained=pretrained, num_classes=num_classes, transform_input=False, **kwargs)
    else:
        assert False, "Unknown model architecture (%s)" % model_name
    return model 
開發者ID:rwightman,項目名稱:pytorch-dpn-pretrained,代碼行數:49,代碼來源:model_factory.py


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