当前位置: 首页>>代码示例>>Python>>正文


Python resnet.resnet34方法代码示例

本文整理汇总了Python中torchvision.models.resnet.resnet34方法的典型用法代码示例。如果您正苦于以下问题:Python resnet.resnet34方法的具体用法?Python resnet.resnet34怎么用?Python resnet.resnet34使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torchvision.models.resnet的用法示例。


在下文中一共展示了resnet.resnet34方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import resnet34 [as 别名]
def __init__(self, skel_desc, pixelwise_loss):
        super().__init__()

        self.data_specs = DataSpecs(
            ImageSpecs(256, mean=ImageSpecs.IMAGENET_MEAN, stddev=ImageSpecs.IMAGENET_STDDEV),
            JointsSpecs(skel_desc, n_dims=3),
        )

        self.pixelwise_loss = pixelwise_loss

        resnet = resnet34(pretrained=True)
        self.in_cnn = ResNetFeatureExtractor(resnet)
        self.xy_hm_cnn = _XYCnn(resnet, skel_desc.n_joints)

        self.zy_hm_cnn = _ChatterboxCnn(skel_desc.n_joints, shrink_width=True)
        self.xz_hm_cnn = _ChatterboxCnn(skel_desc.n_joints, shrink_width=False) 
开发者ID:anibali,项目名称:margipose,代码行数:18,代码来源:chatterbox_model.py

示例2: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import resnet34 [as 别名]
def __init__(self,
                 voxel_dimension=(9,180,240),  # dimension of voxel will be C x 2 x H x W
                 crop_dimension=(224, 224),  # dimension of crop before it goes into classifier
                 num_classes=101,
                 mlp_layers=[1, 30, 30, 1],
                 activation=nn.LeakyReLU(negative_slope=0.1),
                 pretrained=True):

        nn.Module.__init__(self)
        self.quantization_layer = QuantizationLayer(voxel_dimension, mlp_layers, activation)
        self.classifier = resnet34(pretrained=pretrained)

        self.crop_dimension = crop_dimension

        # replace fc layer and first convolutional layer
        input_channels = 2*voxel_dimension[0]
        self.classifier.conv1 = nn.Conv2d(input_channels, 64, kernel_size=7, stride=2, padding=3, bias=False)
        self.classifier.fc = nn.Linear(self.classifier.fc.in_features, num_classes) 
开发者ID:uzh-rpg,项目名称:rpg_event_representation_learning,代码行数:20,代码来源:models.py

示例3: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import resnet34 [as 别名]
def __init__(self, pretrained=True, input_channels=3):
        model = resnet.resnet34(pretrained=pretrained)
        super().__init__(
            model=model,
            input_channels=input_channels) 
开发者ID:PavelOstyakov,项目名称:pipeline,代码行数:7,代码来源:resnet.py

示例4: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import resnet34 [as 别名]
def __init__(self):
        super().__init__()
        rn34 = resnet34(pretrained=True)

        # discard last Resnet block, avrpooling and classification FC
        self.layer1 = nn.Sequential(*list(rn34.children())[:6])
        self.layer2 = nn.Sequential(*list(rn34.children())[6:7])
        # modify conv4 if necessary
        # Always deal with stride in first block
        modulelist = list(self.layer2.children())
        _ModifyBlock(modulelist[0], stride=(1,1)) 
开发者ID:mlperf,项目名称:inference,代码行数:13,代码来源:base_model_r34.py

示例5: create_model

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import resnet34 [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

示例6: __init__

# 需要导入模块: from torchvision.models import resnet [as 别名]
# 或者: from torchvision.models.resnet import resnet34 [as 别名]
def __init__(self, fc_layers=None, dropout=None, pretrained=True):
        super().__init__()

        # Store settings, maybe someone will be interested to see them
        self.fc_layers = fc_layers
        self.dropout = dropout
        self.pretrained = pretrained

        self.head_layers = 8
        self.group_cut_layers = (6, 10)

        # Load backbbone
        backbone = m.resnet34(pretrained=pretrained)

        # If fc layers is set, let's put custom head
        if fc_layers:
            # Take out the old head and let's put the new head
            valid_children = list(backbone.children())[:-2]

            valid_children.extend([
                l.AdaptiveConcatPool2d(),
                l.Flatten()
            ])

            layer_inputs = [NET_OUTPUT] + fc_layers[:-1]

            dropout = dropout or [None] * len(fc_layers)

            for idx, (layer_input, layet_output, layer_dropout) in enumerate(zip(layer_inputs, fc_layers, dropout)):
                valid_children.append(nn.BatchNorm1d(layer_input))

                if layer_dropout:
                    valid_children.append(nn.Dropout(layer_dropout))

                valid_children.append(nn.Linear(layer_input, layet_output))

                if idx == len(fc_layers) - 1:
                    # Last layer
                    valid_children.append(nn.LogSoftmax(dim=1))
                else:
                    valid_children.append(nn.ReLU())

            final_model = nn.Sequential(*valid_children)
        else:
            final_model = backbone

        self.model = final_model 
开发者ID:MillionIntegrals,项目名称:vel,代码行数:49,代码来源:resnet34.py


注:本文中的torchvision.models.resnet.resnet34方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。