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


Python models.vgg11_bn方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import vgg11_bn [as 別名]
def __init__(self, p):
        super(CAL_network, self).__init__()
        self.params = p

        # get feature extractor and first FCN layer from vgg
        vgg = models.vgg11_bn(pretrained=True)
        ls = [l for l in vgg.features]+ [nn.AdaptiveMaxPool2d(1), Flatten()]
        self.features = nn.Sequential(*ls)
        n_in = 512 # fixed amount of features after feature extractor

        # initialize the task blocks
        self.red_light = TaskBlock(params=p, n_in=512, n_out=2)
        self.hazard_stop = TaskBlock(params=p, n_in=512, n_out=2)
        self.speed_sign = TaskBlock(params=p, n_in=512,  n_out=4)
        self.veh_distance = TaskBlock(params=p, n_in=512, n_out=1)
        self.relative_angle = TaskBlock(params=p, n_in=512, n_out=1, cond=True)
        self.center_distance = TaskBlock(params=p, n_in=512, n_out=1, cond=True) 
開發者ID:xl-sr,項目名稱:CAL,代碼行數:19,代碼來源:net.py

示例2: vgg11_bn

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import vgg11_bn [as 別名]
def vgg11_bn(num_classes=1000, pretrained='imagenet'):
    """VGG 11-layer model (configuration "A") with batch normalization
    """
    model = models.vgg11_bn(pretrained=False)
    if pretrained is not None:
        settings = pretrained_settings['vgg11_bn'][pretrained]
        model = load_pretrained(model, num_classes, settings)
    model = modify_vggs(model)
    return model 
開發者ID:alexandonian,項目名稱:pretorched-x,代碼行數:11,代碼來源:torchvision_models.py

示例3: _load_pytorch_model

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import vgg11_bn [as 別名]
def _load_pytorch_model(model_name, summary):
    import torchvision.models as models
    switcher = {
        'alexnet': lambda: models.alexnet(pretrained=True).eval(),
        "vgg11": lambda: models.vgg11(pretrained=True).eval(),
        "vgg11_bn": lambda: models.vgg11_bn(pretrained=True).eval(),
        "vgg13": lambda: models.vgg13(pretrained=True).eval(),
        "vgg13_bn": lambda: models.vgg13_bn(pretrained=True).eval(),
        "vgg16": lambda: models.vgg16(pretrained=True).eval(),
        "vgg16_bn": lambda: models.vgg16_bn(pretrained=True).eval(),
        "vgg19": lambda: models.vgg19(pretrained=True).eval(),
        "vgg19_bn": lambda: models.vgg19_bn(pretrained=True).eval(),
        "resnet18": lambda: models.resnet18(pretrained=True).eval(),
        "resnet34": lambda: models.resnet34(pretrained=True).eval(),
        "resnet50": lambda: models.resnet50(pretrained=True).eval(),
        "resnet101": lambda: models.resnet101(pretrained=True).eval(),
        "resnet152": lambda: models.resnet152(pretrained=True).eval(),
        "squeezenet1_0": lambda: models.squeezenet1_0(pretrained=True).eval(),
        "squeezenet1_1": lambda: models.squeezenet1_1(pretrained=True).eval(),
        "densenet121": lambda: models.densenet121(pretrained=True).eval(),
        "densenet161": lambda: models.densenet161(pretrained=True).eval(),
        "densenet201": lambda: models.densenet201(pretrained=True).eval(),
        "inception_v3": lambda: models.inception_v3(pretrained=True).eval(),
    }

    _load_model = switcher.get(model_name, None)
    _model = _load_model()
    import torch
    if torch.cuda.is_available():
        _model = _model.cuda()
    from perceptron.models.classification.pytorch import PyTorchModel as ClsPyTorchModel
    import numpy as np
    mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1))
    std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1))
    pmodel = ClsPyTorchModel(
        _model, bounds=(
            0, 1), num_classes=1000, preprocessing=(
            mean, std))
    return pmodel 
開發者ID:advboxes,項目名稱:perceptron-benchmark,代碼行數:41,代碼來源:tools.py

示例4: load_pytorch_model

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import vgg11_bn [as 別名]
def load_pytorch_model(model_name):
    import torchvision.models as models
    switcher = {
        'alexnet': lambda: models.alexnet(pretrained=True).eval(),
        "vgg11": lambda: models.vgg11(pretrained=True).eval(),
        "vgg11_bn": lambda: models.vgg11_bn(pretrained=True).eval(),
        "vgg13": lambda: models.vgg13(pretrained=True).eval(),
        "vgg13_bn": lambda: models.vgg13_bn(pretrained=True).eval(),
        "vgg16": lambda: models.vgg16(pretrained=True).eval(),
        "vgg16_bn": lambda: models.vgg16_bn(pretrained=True).eval(),
        "vgg19": lambda: models.vgg19(pretrained=True).eval(),
        "vgg19_bn": lambda: models.vgg19_bn(pretrained=True).eval(),
        "resnet18": lambda: models.resnet18(pretrained=True).eval(),
        "resnet34": lambda: models.resnet34(pretrained=True).eval(),
        "resnet50": lambda: models.resnet50(pretrained=True).eval(),
        "resnet101": lambda: models.resnet101(pretrained=True).eval(),
        "resnet152": lambda: models.resnet152(pretrained=True).eval(),
        "squeezenet1_0": lambda: models.squeezenet1_0(pretrained=True).eval(),
        "squeezenet1_1": lambda: models.squeezenet1_1(pretrained=True).eval(),
        "densenet121": lambda: models.densenet121(pretrained=True).eval(),
        "densenet161": lambda: models.densenet161(pretrained=True).eval(),
        "densenet201": lambda: models.densenet201(pretrained=True).eval(),
        "inception_v3": lambda: models.inception_v3(pretrained=True).eval(),
    }

    _load_model = switcher.get(model_name, None)
    _model = _load_model()
    return _model 
開發者ID:advboxes,項目名稱:perceptron-benchmark,代碼行數:30,代碼來源:tools.py

示例5: vgg11_bn

# 需要導入模塊: from torchvision import models [as 別名]
# 或者: from torchvision.models import vgg11_bn [as 別名]
def vgg11_bn(num_classes=1000, pretrained='imagenet'):
    """VGG 11-layer model (configuration "A") with batch normalization
    """
    model = models.vgg11_bn(pretrained=False)
    if pretrained is not None:
        settings = pretrained_settings['vgg11_bn'][pretrained]
        model = load_pretrained(model, num_classes, settings)
    return model 
開發者ID:CeLuigi,項目名稱:models-comparison.pytorch,代碼行數:10,代碼來源:torchvision_models.py


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