當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。