Esempio n. 1
0
                                        ManifoldAnchorPointsGenerator(manifold=sphere_manifold))

    # ### Bayesian optimization
    # Define the Bayesian optimization
    # An optimizer for the acquisition function can additionally be specified with the "optimizer" parameter
    bo_optimizer = gpflowopt.bo.BayesianOptimizer(domain=domain, acquisition=acq_fct, optimizer=acq_fct_opt,
                                                  scaling=False, verbose=True)
    # Run the Bayessian optimization
    Bopt = bo_optimizer.optimize(test_function, n_iter=nb_iter_bo)
    print(Bopt)

    if display_figures:
        # Plot acquisition function
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_acquisition_sphere(ax, acq_fct, xs=bo_optimizer.acquisition.data[0], opt_x=Bopt.x, true_opt_x=true_min,
                                   elev=10, azim=30, n_elems=100)
        ax.set_title('Acquisition function', fontsize=50)
        plt.show()

        # Plot GP
        fig = plt.figure(figsize=(10, 10))
        ax = Axes3D(fig)
        bo_plot_gp_sphere(ax, model, xs=bo_optimizer.acquisition.data[0], opt_x=Bopt.x, true_opt_x=true_min,
                          true_opt_y=true_opt_val, max_colors=max_colors, elev=10, azim=30, n_elems=100)
        ax.set_title('GP mean', fontsize=50)
        plt.show()

        # Plot GP projected on planes
        fig = plt.figure(figsize=(20, 10))
        bo_plot_gp_sphere_planar(fig, model, var_fact=2., xs=bo_optimizer.acquisition.data[0],
                                 ys=bo_optimizer.acquisition.data[1], opt_x=Bopt.x, opt_y=test_function(Bopt.x),
Esempio n. 2
0
        print("Iteration " + str(iteration) + "\t Best f " +
              str(new_best_f.item()))

    # To numpy
    x_eval = x_data.numpy()
    y_eval = y_data.numpy()[:, None]

    if disp_fig:
        # Plot acquisition function
        fig = plt.figure(figsize=(5, 5))
        ax = Axes3D(fig)
        bo_plot_acquisition_sphere(ax,
                                   acq_fct,
                                   xs=x_eval,
                                   opt_x=best_x[-1][None],
                                   true_opt_x=true_min,
                                   elev=10,
                                   azim=30,
                                   n_elems=100)
        ax.set_title('Acquisition function', fontsize=20)
        plt.show()

        # Plot GP
        fig = plt.figure(figsize=(5, 5))
        ax = Axes3D(fig)
        bo_plot_gp_sphere(ax,
                          model,
                          xs=x_eval,
                          opt_x=best_x[-1][None],
                          true_opt_x=true_min,
                          true_opt_y=true_opt_val,