当前位置: 首页>>代码示例>>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;未经允许,请勿转载。