Exemplo n.º 1
0
def get_split_outputs(Y):
    """Split Y into Y1/Y2 for every output scheme."""
    n = Y.shape[1] - 1
    split_observations = []
    for scheme_idx in range(1, n + 1):
        relevant_cols = [Y[:, 0], Y[:, scheme_idx]]
        split_observations.append(stack_all_columns(relevant_cols))
    return split_observations
Exemplo n.º 2
0
 def _get_augmented_input(self, X, m, input_dim):
     if input_dim > 1:
         # Augment input for GPAR (ignored when using IGPs)
         means, vars = self.global_model.predict_f(X)
         ordered_means = means[:, self.global_model.get_ordering()]
         Y = ordered_means[:, :(input_dim - 1)]
         return stack_all_columns([X, Y])
     else:
         return X
Exemplo n.º 3
0
    def run(self):
        hyp_list = get_bounded_samples(self.hyp_bounds_list, self.n_samples)
        model_aggregator = ModelAggregator(hyp_list)

        start_time = time()
        model_aggregator.train_all_models(self.n_epochs)
        self.training_time = time() - start_time

        losses = model_aggregator.get_all_losses()
        self.min_losses = self._get_min_losses(
            stack_all_columns(losses.values()))
Exemplo n.º 4
0
N_MODELS = 6
N_EPOCHS = 30
N_OBS = 20
NUM_RESTARTS = 0
KERNEL_FUNCTION = get_exponential_decay_kernel
PLOT_SHAPE = (2, 3)

# Construct all models
bounds_list = [[1, 10], [5, 500]]
hyp_list = [sample_from_bounds(bounds_list) for _ in range(N_MODELS)]

# Train all models
model_aggregator = ModelAggregator(hyp_list)
model_aggregator.train_all_models(N_EPOCHS)
losses = model_aggregator.get_all_losses()
Y_true = stack_all_columns(losses.values())

# Get epochs for truth
X_true = np.arange(1, Y_true.shape[0] + 1) \
    .reshape((-1, 1)).astype(float)

# Get observations
X_obs = X_true[:N_OBS]
Y_obs = Y_true[:N_OBS, :]

# Get test points
X_test = X_true

# Run experiment
exp = ExperimentRunner(X_obs,
                       Y_obs,
Exemplo n.º 5
0
        x_value = np.array(X_VALUES[input_idx]).reshape((1, 1))
        X_new = float(x_value) * np.ones((N_NEW, 1))
        Y = y_exp2(X_new, True)
        plot_idx = input_idx
        title = 'x={}'.format(float(x_value))

        plot_noise_histogram(3, len(X_VALUES), plot_idx, Y[:, 0],
                             Y[:, scheme_idx + 1], title)

        # Get GPAR predictions
        indep_out_idx = 0 if ordering[0] == 0 else (scheme_idx + 1)

        gpar_means, gpar_vars = m.predict_single_output(X_new, indep_out_idx)
        Y_indep = get_gpar_output_samples(gpar_means, gpar_vars)

        X_stacked = stack_all_columns([X_new, Y_indep])
        gpar_means, gpar_vars = m.predict_single_output(X_stacked, ordering[1])
        Y_dep = get_gpar_output_samples(gpar_means, gpar_vars)

        Y1_gpar = Y_indep if ordering[0] == 0 else Y_dep
        Y2_gpar = Y_dep if ordering[0] == 0 else Y_indep

        plot_noise_histogram(3, len(X_VALUES), plot_idx + len(X_VALUES),
                             Y1_gpar, Y2_gpar)

        # Get IGP predictions
        Y1_igp = get_igp_output_samples(X_obs, Y_obs, x_value, KERNEL_FUNCTION,
                                        NUM_RESTARTS, 0, N_NEW)
        Y2_igp = get_igp_output_samples(X_obs, Y_obs, x_value, KERNEL_FUNCTION,
                                        NUM_RESTARTS, scheme_idx + 1, N_NEW)
Exemplo n.º 6
0
def format_data(inputs, outputs, data_src):
    labels = outputs.keys() if data_src is None else data_src
    ordered_outputs = get_ordered_outputs(outputs, labels)
    return get_arbitrary_element(inputs), stack_all_columns(
        ordered_outputs), labels