def __init__(self, args): self.model = ACGAN() self.G_optimizer = torch.optim.Adam(self.model.G.parameters(), lr=1e-4, betas=(0.5, 0.999)) self.D_optimizer = torch.optim.Adam(self.model.D.parameters(), lr=1e-4, betas=(0.5, 0.999)) self.criterion = torch.nn.CrossEntropyLoss() self.dataloader = celeba_loader(args.batch_size) self.epochs = args.epochs self.modelpath = 'ckpt/%s/model.pth' % args.taskname self.img_dpath = 'ckpt/' + args.taskname + '/img_%d-%s.png' self.args = args if args.resume is not None: print('resuming model', args.resume) self.model.load(args.resume) self.device = 'cuda' if torch.cuda.is_available() else 'cpu' self.model.to(self.device) self.LAMBDA = 10 self.p = 1 self.q = 1 self.one = torch.FloatTensor([1]).to(self.device) self.mone = self.one * -1 print('finish init')
def __init__(self, args): self.model = DCGAN() self.G_optimizer = torch.optim.Adam(self.model.G.parameters()) self.D_optimizer = torch.optim.Adam(self.model.D.parameters()) self.criterion = torch.nn.BCELoss() self.dataloader = celeba_loader(args.batch_size) self.device = 'cuda' if torch.cuda.is_available() else 'cpu' self.model.to(self.device) self.k = 1 self.epochs = args.epochs self.modelpath = 'ckpt/%s/model.pth' % args.taskname self.img_dpath = 'ckpt/' + args.taskname + '/img_%d.png'
def __init__(self, args): self.model = ACGAN(args) self.G_optimizer = torch.optim.Adam(self.model.G.parameters()) self.D_optimizer = torch.optim.Adam(self.model.D.parameters()) self.criterion = torch.nn.BCELoss() self.label_criterion = torch.nn.CrossEntropyLoss() self.dataloader = celeba_loader(args.batch_size) self.epochs = args.epochs self.modelpath = 'ckpt/%s/model.pth' % args.taskname self.img_dpath = 'ckpt/' + args.taskname + '/img_%d-%s.png' self.args = args if args.resume is not None: print('loading model') self.model.load(self.modelpath) self.device = 'cuda' if torch.cuda.is_available() else 'cpu' self.model.to(self.device) self.p = 1 self.q = 1