本文整理匯總了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
示例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()])
示例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()])