本文整理汇总了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()])