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


Python resnet.resnet50方法代码示例

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


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

示例1: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self, use_nhwc=False, pad_input=False):
        super().__init__()

        if use_nhwc:
            rn50 = resnet50_nhwc(pretrained=True, pad_input=pad_input)
            idx = 5
        else:
            rn50 = resnet50(pretrained=True)
            idx = 6

        # discard last Resnet block, avrpooling and classification FC
        self.layer1 = nn.Sequential(*list(rn50.children())[:idx])
        self.layer2 = nn.Sequential(*list(rn50.children())[idx:idx+1])
        self.layer3 = nn.Sequential(*list(rn50.children())[idx+1:idx+2])

        # modify conv4 if necessary
        padding = None
        # Always deal with stride in first block
        modulelist = list(self.layer2.children())
        _ModifyBlock(modulelist[0], bottleneck=True, stride=(1,1)) 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:22,代码来源:base_model.py

示例2: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self):
        super(FPN, self).__init__()

        self.relu = nn.ReLU(inplace=True)

        # bottom up
        self.resnet = resnet_fpn.resnet50(pretrained=True)

        # top down
        self.upsample = nn.Upsample(scale_factor=2, mode='nearest')
        self.c5_conv = nn.Conv2d(2048, 256, (1, 1))
        self.c4_conv = nn.Conv2d(1024, 256, (1, 1))
        self.c3_conv = nn.Conv2d(512, 256, (1, 1))
        self.c2_conv = nn.Conv2d(256, 256, (1, 1))
        #self.max_pool = nn.MaxPool2d((1, 1), stride=2)

        self.p5_conv = nn.Conv2d(256, 256, (3, 3), padding=1)
        self.p4_conv = nn.Conv2d(256, 256, (3, 3), padding=1)
        self.p3_conv = nn.Conv2d(256, 256, (3, 3), padding=1)
        self.p2_conv = nn.Conv2d(256, 256, (3, 3), padding=1)

        # predict heatmap
        self.sigmoid = nn.Sigmoid()
        self.predict = nn.Conv2d(256, 1, (3, 3), padding=1) 
开发者ID:svip-lab,项目名称:GazeFollowing,代码行数:26,代码来源:gazenet.py

示例3: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self, arch='resnet50'):
        super(visible_module, self).__init__()

        model_v = resnet50(pretrained=True,
                           last_conv_stride=1, last_conv_dilation=1)
        # avg pooling to global pooling
        self.visible = model_v 
开发者ID:mangye16,项目名称:Cross-Modal-Re-ID-baseline,代码行数:9,代码来源:model.py

示例4: GenModelZoo

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def GenModelZoo():
    """  Specify the input shape and model initializing param  """
    return {
        0: (torchvision.models.squeezenet1_1, [1, 3, 224, 224], [True], {}),
        1: (resnet.resnet50, [1, 3, 224, 224], [True], {}),
        2: (torchvision.models.densenet121, [1, 3, 224, 224], [False], {}),
        3: (MobileNet, [1, 3, 224, 224], [], {}),

        17: (models._netG_1, [1, 100, 1, 1], [1, 100, 3, 64, 1], {}),
        18: (FaceBoxes, [1, 3, 224, 224], [], {}),
        20: (UNet.UNet, [1, 3, 64, 64], [2], {}),
    } 
开发者ID:starimeL,项目名称:PytorchConverter,代码行数:14,代码来源:run.py

示例5: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self, pretrained=True):
        """Declare all needed layers."""
        super(ResNet50, self).__init__()
        self.model = resnet.resnet50(pretrained=pretrained)
        self.relu = self.model.relu  # Place a hook

        layers_cfg = [4, 5, 6, 7]
        self.blocks = []
        for i, num_this_layer in enumerate(layers_cfg):
            self.blocks.append(list(self.model.children())[num_this_layer]) 
开发者ID:JaveyWang,项目名称:Pyramid-Attention-Networks-pytorch,代码行数:12,代码来源:networks.py

示例6: initialize_encoder

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def initialize_encoder(model_name, num_classes, use_pretrained=True):
    # Initialize these variables which will be set in this if statement. Each of these
    #   variables is model specific.
    model_ft = None

    if model_name == "resnet18":
        """ Resnet18
        """
        model_ft = resnet.resnet18(pretrained=use_pretrained, num_classes=1000)
        num_ftrs = model_ft.fc.in_features
        model_ft.fc = nn.Linear(num_ftrs, num_classes)

    elif model_name == "resnet34":
        """ Resnet34
        """
        model_ft = resnet.resnet34(pretrained=use_pretrained, num_classes=1000)
        num_ftrs = model_ft.fc.in_features
        model_ft.fc = nn.Linear(num_ftrs, num_classes)

    elif model_name == "resnet50":
        """ Resnet50
        """
        model_ft = resnet.resnet50(pretrained=use_pretrained, num_classes=1000)
        num_ftrs = model_ft.fc.in_features
        model_ft.fc = nn.Linear(num_ftrs, num_classes)

    else:
        print("Invalid model name, exiting...")
        exit()

    return model_ft

# full model 
开发者ID:zouchuhang,项目名称:Silhouette-Guided-3D,代码行数:35,代码来源:model.py

示例7: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self, pretrain=False):
        super(ResDown, self).__init__()
        self.features = resnet50(layer3=True, layer4=False)
        if pretrain:
            load_pretrain(self.features, 'resnet.model')

        self.downsample = ResDownS(1024, 256)
        self.layers = [self.downsample, self.features.layer2, self.features.layer3]
        self.train_nums = [1, 3]
        self.change_point = [0, 0.5]

        self.unfix(0.0) 
开发者ID:foolwood,项目名称:SiamMask,代码行数:14,代码来源:custom.py

示例8: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self, pretrain=False):
        super(ResDown, self).__init__()
        self.features = resnet50(layer3=True, layer4=False)
        if pretrain:
            load_pretrain(self.features, 'resnet.model')

        self.downsample = ResDownS(1024, 256)

        self.layers = [self.downsample, self.features.layer2, self.features.layer3]
        self.train_nums = [1, 3]
        self.change_point = [0, 0.5]

        self.unfix(0.0) 
开发者ID:foolwood,项目名称:SiamMask,代码行数:15,代码来源:custom.py

示例9: __init__

# 需要导入模块: import resnet [as 别名]
# 或者: from resnet import resnet50 [as 别名]
def __init__(self):
        super(ResNetBackBone, self).__init__()
        
        modelPreTrain50 = resnet.resnet50(pretrained=True)
        self.model = modelPreTrain50 
开发者ID:zhangboshen,项目名称:A2J,代码行数:7,代码来源:model.py


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