def load_networks(self, verbose=True): self.modules_on_one_gpu.load_networks(verbose) if self.opt.restore_O_path is not None: for i, optimizer in enumerate(self.optimizers): path = '%s-%d.pth' % (self.opt.restore_O_path, i) util.load_optimizer(optimizer, path, verbose) for param_group in optimizer.param_groups: param_group['lr'] = self.opt.lr
def load_networks(self, verbose=True): for name in self.model_names: net = getattr(self, 'net' + name, None) path = getattr(self.opt, 'restore_%s_path' % name, None) if path is not None: util.load_network(net, path, verbose) if self.isTrain: if self.opt.restore_O_path is not None: for i, optimizer in enumerate(self.optimizers): path = '%s-%d.pth' % (self.opt.restore_O_path, i) util.load_optimizer(optimizer, path, verbose) for param_group in optimizer.param_groups: param_group['lr'] = self.opt.lr
def load_networks(self, verbose=True): self.modules_on_one_gpu.load_networks(verbose) if self.isTrain and self.opt.restore_O_path is not None: for i, optimizer in enumerate(self.optimizers): path = '%s-%d.pth' % (self.opt.restore_O_path, i) util.load_optimizer(optimizer, path, verbose) if self.opt.no_TTUR: G_lr, D_lr = self.opt.lr, self.opt.lr else: G_lr, D_lr = self.opt.lr / 2, self.opt.lr * 2 for param_group in self.optimizer_G.param_groups: param_group['lr'] = G_lr for param_group in self.optimizer_D.param_groups: param_group['lr'] = D_lr
def load_networks(self, verbose=True): util.load_network(self.netG_teacher, self.opt.restore_teacher_G_path, verbose) if self.opt.restore_student_G_path is not None: util.load_network(self.netG_student, self.opt.restore_student_G_path, verbose) if self.opt.restore_D_path is not None: util.load_network(self.netD, self.opt.restore_D_path, verbose) if self.opt.restore_A_path is not None: for i, netA in enumerate(self.netAs): path = '%s-%d.pth' % (self.opt.restore_A_path, i) util.load_network(netA, path, verbose) if self.opt.restore_O_path is not None: for i, optimizer in enumerate(self.optimizers): path = '%s-%d.pth' % (self.opt.restore_O_path, i) util.load_optimizer(optimizer, path, verbose)
def load_networks(self, verbose=True): util.load_network(self.netG_teacher, self.opt.restore_teacher_G_path, verbose) if self.opt.restore_student_G_path is not None: util.load_network(self.netG_student, self.opt.restore_student_G_path, verbose) if hasattr(self, 'netG_student_tmp'): util.load_network(self.netG_student_tmp, self.opt.restore_student_G_path, verbose) if self.opt.restore_D_path is not None: util.load_network(self.netD, self.opt.restore_D_path, verbose) if self.opt.restore_A_path is not None: for i, netA in enumerate(self.netAs): path = '%s-%d.pth' % (self.opt.restore_A_path, i) util.load_network(netA, path, verbose) if self.opt.restore_O_path is not None: for i, optimizer in enumerate(self.optimizers): path = '%s-%d.pth' % (self.opt.restore_O_path, i) util.load_optimizer(optimizer, path, verbose) for param_group in optimizer.param_groups: param_group['lr'] = self.opt.lr
def load_networks(self, model_weight=None): if self.cfgs.restore_teacher_G_path is None: assert len( model_weight ) != 0, "restore_teacher_G_path and model_weight cannot be None at the same time." if self.cfgs.direction == 'AtoB': key = 'netG_A' if 'netG_A' in model_weight else 'netG_teacher' self.netG_teacher.set_dict(model_weight[key]) else: key = 'netG_B' if 'netG_B' in model_weight else 'netG_teacher' self.netG_teacher.set_dict(model_weight[key]) else: util.load_network(self.netG_teacher, self.cfgs.teacher_G_path) if self.cfgs.restore_student_G_path is not None: util.load_network(self.netG_student, self.cfgs.restore_student_G_path) else: if self.task == 'supernet': self.netG_student.set_dict(model_weight['netG_student']) if self.cfgs.restore_D_path is not None: util.load_network(self.netD, self.cfgs.restore_D_path) else: if self.cfgs.direction == 'AtoB': key = 'netD_A' if 'netD_A' in model_weight else 'netD' self.netD.set_dict(model_weight[key]) else: key = 'netD_B' if 'netD_B' in model_weight else 'netD' self.netD.set_dict(model_weight[key]) if self.cfgs.restore_A_path is not None: for i, netA in enumerate(self.netAs): netA_path = '%s-%d.pth' % (self.cfgs.restore_A_path, i) util.load_network(netA, netA_path) if self.cfgs.restore_O_path is not None: util.load_optimizer(self.optimizer_G, self.cfgs.restore_G_optimizer_path) util.load_optimizer(self.optimizer_D, self.cfgs.restore_D_optimizer_path)
def load_networks(self, verbose=True): self.modules_on_one_gpu.load_networks(verbose) if self.isTrain and self.opt.restore_O_path is not None: for i, optimizer in enumerate(self.optimizers): path = '%s-%d.pth' % (self.opt.restore_O_path, i) util.load_optimizer(optimizer, path, verbose)