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


Python resnet.ResNet18方法代码示例

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


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

示例1: create_model

# 需要导入模块: from models import resnet [as 别名]
# 或者: from models.resnet import ResNet18 [as 别名]
def create_model(self):
        local_model = ResNet18(name='Local',
                    created_time=self.params['current_time'])
        local_model.cuda()
        target_model = ResNet18(name='Target',
                        created_time=self.params['current_time'])
        target_model.cuda()
        if self.params['resumed_model']:
            loaded_params = torch.load(f"saved_models/{self.params['resumed_model']}")
            target_model.load_state_dict(loaded_params['state_dict'])
            self.start_epoch = loaded_params['epoch']
            self.params['lr'] = loaded_params.get('lr', self.params['lr'])
            logger.info(f"Loaded parameters from saved model: LR is"
                        f" {self.params['lr']} and current epoch is {self.start_epoch}")
        else:
            self.start_epoch = 1

        self.local_model = local_model
        self.target_model = target_model 
开发者ID:ebagdasa,项目名称:backdoor_federated_learning,代码行数:21,代码来源:image_helper.py

示例2: model_loader

# 需要导入模块: from models import resnet [as 别名]
# 或者: from models.resnet import ResNet18 [as 别名]
def model_loader():
    model = {'resnet18': ResNet18,
             'resnet18_dropout': ResNet18Dropout,
             'resnet18_adf': ResNet18ADF,
             'resnet18_dropout_adf': ResNet18ADFDropout,
             }
    
    params = {'resnet18': [],
             'resnet18_dropout': [args.p],
             'resnet18_adf': [args.noise_variance, args.min_variance],
             'resnet18_dropout_adf': [args.p, args.noise_variance, args.min_variance],
             }
    
    return model[args.test_model_name.lower()](*params[args.test_model_name.lower()]) 
开发者ID:mattiasegu,项目名称:uncertainty_estimation_deep_learning,代码行数:16,代码来源:eval.py

示例3: model_loader

# 需要导入模块: from models import resnet [as 别名]
# 或者: from models.resnet import ResNet18 [as 别名]
def model_loader():
    model = {'resnet18': ResNet18,
             'resnet18_dropout': ResNet18Dropout,
             'resnet18_adf': ResNet18ADF,
             'resnet18_dropout_adf': ResNet18ADFDropout,
             }
    
    params = {'resnet18': [],
             'resnet18_dropout': [args.p],
             'resnet18_heteroscedastic': [args.p],
             'resnet18_adf': [args.noise_variance, args.min_variance],
             'resnet18_dropout_adf': [args.p, args.noise_variance, args.min_variance],
             }
    
    return model[args.model_name.lower()](*params[args.model_name.lower()]) 
开发者ID:mattiasegu,项目名称:uncertainty_estimation_deep_learning,代码行数:17,代码来源:train.py


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