opt.seed = random.randint(1, 1200) torch.manual_seed(opt.seed) torch.cuda.manual_seed(opt.seed) if opt.resume: if os.path.isfile(opt.resume): print("Loading from checkpoint {}".format(opt.resume)) model = torch.load(opt.resume) model.load_state_dict(model.state_dict()) netD = torch.load(opt.resumeD) netD.load_state_dict(netD.state_dict()) opt.start_training_step, opt.start_epoch = which_trainingstep_epoch( opt.resume) else: model = Net() netD = Discriminator() mkdir_steptraing() # model = torch.load('models/1/GFN_epoch_1.pkl') # model.load_state_dict(model.state_dict()) # netD = torch.load('models/1/GFN_D_epoch_1.pkl') # netD.load_state_dict(netD.state_dict()) model = model.to(device) netD = netD.to(device) criterion = torch.nn.MSELoss(size_average=True) criterion = criterion.to(device) cri_perception = VGGFeatureExtractor().to(device) cri_gan = GANLoss('vanilla', 1.0, 0.0).to(device)
opt.seed = random.randint(1, 1200) torch.manual_seed(opt.seed) torch.cuda.manual_seed(opt.seed) if opt.resume: if os.path.isfile(opt.resume): print("Loading from checkpoint {}".format(opt.resume)) model = torch.load(opt.resume) model.load_state_dict(model.state_dict()) netD = torch.load(opt.resumeD) netD.load_state_dict(netD.state_dict()) opt.start_training_step, opt.start_epoch = which_trainingstep_epoch( opt.resume) else: model = Net() netD = Discriminator() mkdir_steptraing() model = model.to(device) netD = netD.to(device) criterion = torch.nn.L1Loss(size_average=True) criterion = criterion.to(device) cri_perception = VGGFeatureExtractor().to(device) optimizer = torch.optim.Adam( filter(lambda p: p.requires_grad, model.parameters()), 0.0001, [0.9, 0.999]) optimizer_D = torch.optim.Adam( filter(lambda p: p.requires_grad, netD.parameters()), 0.0002, [0.9, 0.999]) print()
torch.manual_seed(opt.seed) torch.cuda.manual_seed(opt.seed) if opt.resume: if os.path.isfile(opt.resume): print("Loading from checkpoint {}".format(opt.resume)) model = torch.load(opt.resume) model.load_state_dict(model.state_dict()) # netD = torch.load(opt.resumeD) # netD.load_state_dict(netD.state_dict()) opt.start_training_step, opt.start_epoch = which_trainingstep_epoch(opt.resume) else: model = Net() # netD = Discriminator() mkdir_steptraing() model = model.to(device) # netD = netD.to(device) criterion = torch.nn.MSELoss(size_average=True) criterion = criterion.to(device) cri_perception = VGGFeatureExtractor().to(device) # textual init vgg19 = cri_perception.vggNet loss_layer = [1, 6, 11, 20] loss_fns = [GramMSELoss()] * len(loss_layer) if torch.cuda.is_available():
torch.manual_seed(opt.seed) torch.cuda.manual_seed(opt.seed) if opt.resume: if os.path.isfile(opt.resume): print("Loading from checkpoint {}".format(opt.resume)) model = torch.load(opt.resume) model.load_state_dict(model.state_dict()) netD = torch.load(opt.resumeD) netD.load_state_dict(netD.state_dict()) opt.start_training_step, opt.start_epoch = which_trainingstep_epoch(opt.resume) else: model = Net() netD = Discriminator() mkdir_steptraing() # model = torch.load('models/1/GFN_epoch_1.pkl') # model.load_state_dict(model.state_dict()) # netD = torch.load('models/1/GFN_D_epoch_1.pkl') # netD.load_state_dict(netD.state_dict()) model = model.to(device) netD = netD.to(device) criterion = torch.nn.L1Loss(size_average=True) criterion = criterion.to(device) cri_perception = VGGFeatureExtractor().to(device) cri_gan = GANLoss('vanilla', 1.0, 0.0).to(device)