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


Python vgg.VGG屬性代碼示例

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


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

示例1: get_vgg_cfg

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def get_vgg_cfg(model):
    """
    return config list to generate VGG instance
    :param model: class VGG (torch.nn.Module), model to prune
    :return:
        list, config list to generate VGG instance
    """
    assert isinstance(model, models.VGG)
    features = model.features
    if isinstance(features, torch.nn.DataParallel):
        features = features.module

    cfg = []
    batch_norm = False
    for m in features:
        if isinstance(m, torch.nn.modules.conv._ConvNd):
            cfg.append(m.out_channels)
        elif isinstance(m, torch.nn.modules.pooling._MaxPoolNd):
            cfg.append('M')
        elif isinstance(m, torch.nn.modules.batchnorm._BatchNorm):
            batch_norm = True

    return cfg, batch_norm 
開發者ID:synxlin,項目名稱:nn-compression,代碼行數:25,代碼來源:prune_train.py

示例2: vgg11

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg11(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['A']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例3: vgg11_bn

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg11_bn(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['A'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例4: vgg13

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg13(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['B']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例5: vgg13_bn

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg13_bn(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['B'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例6: vgg16

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg16(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['D']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg16']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例7: vgg19

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg19(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['E']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg19']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例8: vgg19_bn

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg19_bn(config_channels, anchors, num_cls):
    model = VGG(config_channels, anchors, num_cls, make_layers(config_channels, cfg['E'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg19_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:yolo2-pytorch,代碼行數:13,代碼來源:vgg.py

示例9: get_vgg

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def get_vgg(in_channels=3, **kwargs):
  model = VGG(make_layers(cfg['D'], in_channels), **kwargs)
  return model 
開發者ID:google,項目名稱:graph_distillation,代碼行數:5,代碼來源:get_cnn.py

示例10: make_dilated

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def make_dilated(self, stage_list, dilation_list):
        raise ValueError("'VGG' models do not support dilated mode due to Max Pooling"
                         " operations for downsampling!") 
開發者ID:qubvel,項目名稱:segmentation_models.pytorch,代碼行數:5,代碼來源:vgg.py

示例11: forward

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def forward(self, x):
        output = {}

        # get the output of each maxpooling layer (5 maxpool in VGG net)
        for idx in range(len(self.ranges)):
            for layer in range(self.ranges[idx][0], self.ranges[idx][1]):
                x = self.features[layer](x)
            output["x%d"%(idx+1)] = x

        return output 
開發者ID:ELEKTRONN,項目名稱:elektronn3,代碼行數:12,代碼來源:fcn_2d.py

示例12: vgg_face

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg_face(pretrained=False, **kwargs):
    if pretrained:
        kwargs['init_weights'] = False
    model = vgg.VGG(vgg.make_layers(vgg.cfgs['D'], batch_norm=False), num_classes=2622, **kwargs)
    if pretrained:
        model.load_state_dict(vgg_face_state_dict())
    return model 
開發者ID:grey-eye,項目名稱:talking-heads,代碼行數:9,代碼來源:vgg.py

示例13: vgg11

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg11(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['A']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:openpose-pytorch,代碼行數:13,代碼來源:vgg.py

示例14: vgg11_bn

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg11_bn(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['A'], batch_norm=True))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg11_bn']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:openpose-pytorch,代碼行數:13,代碼來源:vgg.py

示例15: vgg13

# 需要導入模塊: from torchvision.models import vgg [as 別名]
# 或者: from torchvision.models.vgg import VGG [as 別名]
def vgg13(config_channels):
    model = VGG(config_channels, make_layers(config_channels, cfg['B']))
    if config_channels.config.getboolean('model', 'pretrained'):
        url = model_urls['vgg13']
        logging.info('use pretrained model: ' + url)
        state_dict = model.state_dict()
        for key, value in model_zoo.load_url(url).items():
            if key in state_dict:
                state_dict[key] = value
        model.load_state_dict(state_dict)
    return model 
開發者ID:ruiminshen,項目名稱:openpose-pytorch,代碼行數:13,代碼來源:vgg.py


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