help='number of frames in an animation for the gif') opt = parser.parse_args() print(opt) mnist = MNIST() mnist_train = mnist.train_loader if opt.cuda: cuda_gpu = torch.device('cuda:0') cppn = CPPN(x_dim=opt.x_dim, y_dim=opt.y_dim, scale=opt.scale, cuda_device=cuda_gpu) cppn.cuda() cppn.load_state_dict(torch.load(opt.model)) else: cppn = CPPN(x_dim=opt.x_dim, y_dim=opt.y_dim, scale=opt.scale) cppn.load_state_dict(torch.load(opt.model, map_location='cpu')) cppn.eval() enc = [] lab = [] for idx, (im, label) in enumerate(mnist_train): with torch.no_grad(): if opt.cuda: im = im.cuda() mean, logvar = cppn.encoder(im) encoding = cppn.reparametrize(mean, logvar)
help='number of cpu threads to use during\ batch generation') opt = parser.parse_args() print(opt) mnist = MNIST() train_mnist = mnist.train_loader test = mnist.test_loader if opt.cuda: cuda_gpu = torch.device('cuda:0') model = CPPN(cuda_device=cuda_gpu) model.cuda() else: model = CPPN() le = 0 ld = 0 lg = 0 indices_train = np.arange(60000) model.train() for epoch in range(opt.n_epochs): print("STARTING EPOCH {}".format(epoch)) for idx, (im, _) in enumerate(train_mnist): model.optimizer_discriminator.zero_grad() model.optimizer_encoder.zero_grad()