# set up simulator def simulator(theta): s_of_theta = model.model_sim(theta, True) return func.normalize_summary_stats(s_of_theta, m_s_of_prior, s_s_of_prior) hyper_params = [0.001, 0.001, 0.9, 0.9] # lr_like, lr_post, gamma_post, gamma if lambda_val > 0: hyper_params[-1] = lambda_val if hp_tuning >= 2: hyper_params = func.sample_hp("snpla", hp_tuning) print(hyper_params) flow_lik, flow_post = func.set_up_networks() optimizer_lik = torch.optim.Adam(flow_lik.parameters(), lr=hyper_params[0]) optimizer_post = torch.optim.Adam(flow_post.parameters(), lr=hyper_params[1], weight_decay=0.0) # used def value before decay_rate_post = hyper_params[2] # no adaptation of Adam's base rate nbr_rounds = 5 prob_prior_decay_rate = hyper_params[3] prob_prior = snpla.calc_prob_prior(nbr_rounds, prob_prior_decay_rate) print(prob_prior) nbr_lik = [1000, 1000, 1000, 1000, 1000] # , 2000, 2000]
'/home/samuel/Documents/projects/seq posterior approx w nf/seq posterior approx w nf dev/two_moons' ) sys.path.append('./') print(os.getcwd()) id_job = str(dim) + '_' + str(seed) + '_' + str(seed_data) if hp_tuning > 0: id_job = id_job + "_" + str(hp_tuning) import functions as func print(hp_tuning) print(func.sample_hp("snl", hp_tuning)) print(torch.rand(1)) print(func.sample_hp("snl", hp_tuning)[0].item()) print(torch.rand(1)) prior = BoxUniform(low=-2 * torch.ones(2), high=2 * torch.ones(2)) x_o, model = func.set_up_model(prior) def simulator(theta): return torch.from_numpy( model.gen_single(theta)).to(dtype=torch.float32).reshape(1, 2)
sys.path.append('./') print(os.getcwd()) id_job = str(seed) + '_' + str(seed_data) if hp_tuning > 0: id_job = id_job + "_" + str(hp_tuning) # Load all utility functions for all methods import LotkaVolterra import functions as func # Set model and generate data print(hp_tuning) print(func.sample_hp("snl", hp_tuning)) print(torch.rand(1)) print(func.sample_hp("snl", hp_tuning)) print(torch.rand(1)) # Set model and generate data x_o, model, theta_true = func.set_up_model() m_s_of_prior, s_s_of_prior = func.load_summary_stats_mean_and_std() # set up simulator def simulator(theta): s_of_theta = model.model_sim(theta) return func.normalize_summary_stats(s_of_theta, m_s_of_prior, s_s_of_prior)