def select_best_generators(self):
        # computing metrics
        gan_metrics = compute_metrics(self.target, self.cond_input, self.prob_config, self.check_config, self.coord_input, self.neighbours)
        min_rmse_val = None
        min_mie_val = None
        # selecting and sampling gan
        for criteria in list(self.check_config["perf_metrics"].keys()):   # criteria is either RMSE or MIE
            # find best config
            criteria_info = self.check_config["pf_metrics_setting"][criteria]
            perf_metrics = gan_metrics[criteria_info["metric_level"]]
            perf_values = criteria_info["agg_function"](perf_metrics[[criteria]])
            # print("perf_values for "+criteria,perf_values) # just out of curiosity
            if(criteria == "RMSE"):
                min_rmse_val = perf_values[criteria_info["rank_function"](perf_values)]
                print("min perf_value for "+criteria, min_rmse_val)
            else:
                min_mie_val = perf_values[criteria_info["rank_function"](perf_values)]
                print("min perf_value for "+criteria, min_mie_val)

            best_config = perf_metrics.index[criteria_info["rank_function"](perf_values)]  # the training step that has the best generator
            print("best "+criteria+" at iteration ",best_config) # just out of curiosity

            # generate samples of synthetic data    
            gan_samples_df = self.generate_samples(best_config)
            # pdb.set_trace()
            # if curious, print out gan_sample_df and its shape and its header

            # export results
            self.save_model(gan_samples_df, "grid_" + criteria + ".pkl.gz")
        self.save_model(gan_metrics["agg_metrics"], "grid_checkmetrics.pkl.gz")
Exemplo n.º 2
0
gen_method = Generator(prob_config["cond_dim"], prob_config["noise_dim"],
                       prob_config["output_dim"])
gen_method.to(prob_config["device"])

# training SpaceGAN
spacegan = SpaceGAN(prob_config, check_config, disc_method, gen_method)
spacegan.train(x_train=cond_input, y_train=target, coords=coord_input)

# export final model and data
spacegan.checkpoint_model(spacegan.epochs)
spacegan.df_losses.to_pickle(model_save_prefix + "grid_spaceganlosses.pkl.gz")

# pick the best Generator (G) as determined by the MIE and the RMSE criterion.

# computing metrics
gan_metrics = compute_metrics(target, cond_input, prob_config, check_config,
                              coord_input, neighbours)

# selecting and sampling gan
for criteria in list(check_config["perf_metrics"].keys()):
    # find best config
    criteria_info = check_config["pf_metrics_setting"][criteria]
    perf_metrics = gan_metrics[criteria_info["metric_level"]]
    perf_values = criteria_info["agg_function"](perf_metrics[[criteria]])
    best_config = perf_metrics.index[criteria_info["rank_function"](
        perf_values)]

    # get and set best space gan
    best_spacegan = get_spacegan_config(int(best_config), prob_config,
                                        check_config, cond_input, target)
    # training samples
    gan_samples_df = pd.DataFrame(index=range(cond_input.shape[0]),
Exemplo n.º 3
0
    gen_method = spacegan_config.Generator(
        spacegan_config.prob_config["cond_dim"],
        spacegan_config.prob_config["noise_dim"],
        spacegan_config.prob_config["output_dim"])
    gen_method.to(spacegan_config.prob_config["device"])

    # training SpaceGAN
    spacegan = spacegan_method.SpaceGAN(spacegan_config.prob_config,
                                        spacegan_config.check_config,
                                        disc_method, gen_method)
    spacegan.train(x_train=cond_input, y_train=target, coords=coord_input)
    spacegan.checkpoint_model(spacegan.epochs)  # export final model and data

    # computing metrics
    gan_metrics = spacegan_selection.compute_metrics(
        target, cond_input, spacegan_config.prob_config,
        spacegan_config.check_config, coord_input, spacegan_config.neighbours)

    # selecting and sampling gan
    for criteria in list(spacegan_config.check_config["perf_metrics"].keys()):
        # find best config
        criteria_info = spacegan_config.check_config["pf_metrics_setting"][
            criteria]
        perf_metrics = gan_metrics[criteria_info["metric_level"]]
        perf_values = criteria_info["agg_function"](perf_metrics[[criteria]])
        best_config = perf_metrics.index[criteria_info["rank_function"](
            perf_values)]

        # get and set best space gan
        best_spacegan = spacegan_selection.get_spacegan_config(
            int(best_config), spacegan_config.prob_config,