Esempio n. 1
0
    def get_OracleKernelAdaptiveLangevin_instance(D, target_log_pdf):
        step_size = 1.
        m = 500
        N = 5000
        Z = sample_banana(N, D, bananicity, V)

        surrogate = KernelExpFiniteGaussian(sigma=10, lmbda=.001, m=m, D=D)
        surrogate.fit(Z)

        if False:
            param_bounds = {'sigma': [-2, 3]}
            bo = BayesOptSearch(surrogate, Z, param_bounds)
            best_params = bo.optimize()
            surrogate.set_parameters_from_dict(best_params)

        if False:
            sigma = 1. / gamma_median_heuristic(Z)
            surrogate.set_parameters_from_dict({'sigma': sigma})

        logger.info("kernel exp family uses %s" % surrogate.get_parameters())

        if False:
            import matplotlib.pyplot as plt
            Xs = np.linspace(-30, 30, 50)
            Ys = np.linspace(-20, 40, 50)
            visualise_fit_2d(surrogate, Z, Xs, Ys)
            plt.show()

        instance = OracleKernelAdaptiveLangevin(D, target_log_pdf, surrogate,
                                                step_size)

        return instance
Esempio n. 2
0
 def get_OracleKernelAdaptiveLangevin_instance(D, target_log_pdf):
     step_size = 1.
     m = 500
     N = 5000
     Z = sample_banana(N, D, bananicity, V)
     
     surrogate = KernelExpFiniteGaussian(sigma=10, lmbda=.001, m=m, D=D)
     surrogate.fit(Z)
     
     if False:
         param_bounds = {'sigma': [-2, 3]}
         bo = BayesOptSearch(surrogate, Z, param_bounds)
         best_params = bo.optimize()
         surrogate.set_parameters_from_dict(best_params)
     
     if False:
         sigma = 1. / gamma_median_heuristic(Z)
         surrogate.set_parameters_from_dict({'sigma': sigma})
     
     logger.info("kernel exp family uses %s" % surrogate.get_parameters())
 
     if False:
         import matplotlib.pyplot as plt
         Xs = np.linspace(-30, 30, 50)
         Ys = np.linspace(-20, 40, 50)
         visualise_fit_2d(surrogate, Z, Xs, Ys)
         plt.show()
         
     instance = OracleKernelAdaptiveLangevin(D, target_log_pdf, surrogate, step_size)
     
     return instance
Esempio n. 3
0
    def get_KernelAdaptiveLangevin_instance(D, target_log_pdf):
        step_size = 1.
        m = 500
        
        surrogate = KernelExpFiniteGaussian(sigma=10, lmbda=1., m=m, D=D)
        logger.info("kernel exp family uses %s" % surrogate.get_parameters())
        
        instance = KernelAdaptiveLangevin(D, target_log_pdf, surrogate, step_size)

        return instance
Esempio n. 4
0
    def get_KernelAdaptiveLangevin_instance(D, target_log_pdf):
        step_size = 1.
        m = 500

        surrogate = KernelExpFiniteGaussian(sigma=10, lmbda=1., m=m, D=D)
        logger.info("kernel exp family uses %s" % surrogate.get_parameters())

        instance = KernelAdaptiveLangevin(D, target_log_pdf, surrogate,
                                          step_size)

        return instance