def test_2Dexperiment(): c = Config() c.batch_size = 200 c.n_epochs = 40 c.learning_rate = 0.001 if torch.cuda.is_available(): c.use_cuda = True else: c.use_cuda = False c.rnd_seed = 1 c.log_interval = 200 # model-specific c.n_coupling = 8 c.prior = 'gauss' exp = SmileyExperiment( c, name='gauss', n_epochs=c.n_epochs, seed=42, base_dir='experiment_dir', loggers={'visdom': ['visdom', { "exp_name": "myenv" }]}) exp.run() # sampling samples = exp.model.sample(1000).cpu().numpy() sns.jointplot(samples[:, 0], samples[:, 1]) plt.show()
def test_MNIST_experiment(): c = Config() c.batch_size = 64 c.n_epochs = 50 c.learning_rate = 0.001 c.weight_decay = 5e-5 if torch.cuda.is_available(): c.use_cuda = True else: c.use_cuda = False c.rnd_seed = 1 c.log_interval = 100 c.subset_size = 10 # model-specific c.n_coupling = 8 c.n_filters = 64 exp = MNISTExperiment( c, name='mnist_test', n_epochs=c.n_epochs, seed=42, base_dir='experiment_dir', loggers={'visdom': ['visdom', { "exp_name": "myenv" }]}) exp.run() exp.model.eval() exp.model.to('cpu') with torch.no_grad(): samples = exp.model.sample(16, device='cpu') img_grid = make_grid(samples).permute((1, 2, 0)) plt.imshow(img_grid) plt.show() return exp.model