def prior_update_gan_noise(particles, inputs, model_no): netG = net.G(5, 3, 64) netG.load_state_dict( torch.load( '%s/netG_epoch_%d.pth' % ('/home/gtx1080/Abduallah/pix2pix.pytorch/imglog/fluid_noise', model_no))) netG.eval() netG.cuda() mu = np.load( '/home/gtx1080/Sync/Kun/30_min_ele/non_ele_whole/train/mu.npy') var = np.load( '/home/gtx1080/Sync/Kun/30_min_ele/non_ele_whole/train/var.npy') particles = np.concatenate((particles, inputs), axis=1) particles, label = normalization_test(particles, particles[:, 0:3, :, :], mu, var) particles = torch.tensor(particles, dtype=torch.float).cuda() with torch.no_grad(): particles = netG(particles) particles = np.array(particles.cpu()) particles[:, 0, :, :] = particles[:, 0, :, :] * np.sqrt(var[5, 0]) + mu[5, 0] particles[:, 1, :, :] = particles[:, 1, :, :] * np.sqrt(var[6, 0]) + mu[6, 0] particles[:, 2, :, :] = particles[:, 2, :, :] * np.sqrt(var[7, 0]) + mu[7, 0] particles[:, 0, :, :] = np.maximum(particles[:, 0, :, :], 0) return particles
mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5), split='val', shuffle=False, seed=opt.manualSeed) # get logger trainLogger = open('%s/train.log' % opt.exp, 'w') ngf = opt.ngf ndf = opt.ndf inputChannelSize = opt.inputChannelSize outputChannelSize = opt.outputChannelSize # get models netG = net.G(inputChannelSize, outputChannelSize, ngf) netG.apply(weights_init) if opt.netG != '': netG.load_state_dict(torch.load(opt.netG)) print(netG) netD = net.D(inputChannelSize + outputChannelSize, ndf) netD.apply(weights_init) if opt.netD != '': netD.load_state_dict(torch.load(opt.netD)) print(netD) netG.train() netD.train() criterionBCE = nn.BCELoss() criterionCAE = nn.L1Loss()
seed=opt.manualSeed) ngf = opt.ngf ndf = opt.ndf inputChannelSize = opt.inputChannelSize outputChannelSize = opt.outputChannelSize # get models #import pdb; pdb.set_trace() netG_BEGAN = netBEGAN.G(inputChannelSize, outputChannelSize, ngf) netG_BEGAN.apply(weights_init) if opt.netG_BEGAN != '': netG_BEGAN.load_state_dict(torch.load(opt.netG_BEGAN)) print(netG_BEGAN) netG_GAN = netGAN.G(inputChannelSize, outputChannelSize, ngf) netG_GAN.apply(weights_init) if opt.netG_GAN != '': netG_GAN.load_state_dict(torch.load(opt.netG_GAN)) print(netG_GAN) netG_BEGAN.train() netG_GAN.train() val_target = torch.FloatTensor(opt.tstBatchSize, outputChannelSize, opt.imageSize, opt.imageSize) val_input = torch.FloatTensor(opt.tstBatchSize, inputChannelSize, opt.imageSize, opt.imageSize) netG_BEGAN.cuda() netG_GAN.cuda()