Beispiel #1
0
 def test_ChecKGrads_LCB(self):
     acquisition_lcb = acquisition_for_test(
         AcquisitionLCB(self.model, self.feasible_region))
     grad_lcb = GradientChecker(acquisition_lcb.acquisition_function,
                                acquisition_lcb.d_acquisition_function,
                                self.X_test)
     self.assertTrue(grad_lcb.checkgrad(tolerance=self.tolerance))
 def test_ChecKGrads_MPI(self):
     acquisition_mpi = AcquisitionMPI(1)
     acquisition_mpi.set_model(self.model)
     grad_mpi = GradientChecker(
         acquisition_mpi.acquisition_function, acquisition_mpi.d_acquisition_function, self.X_test
     )
     self.assertTrue(grad_mpi.checkgrad(tolerance=self.tolerance))
Beispiel #3
0
 def test_ChecKGrads_MPI(self):
     acquisition_mpi = acquisition_for_test(
         AcquisitionMPI(self.model, self.feasible_region))
     grad_mpi = GradientChecker(acquisition_mpi.acquisition_function,
                                acquisition_mpi.d_acquisition_function,
                                self.X_test)
     self.assertTrue(grad_mpi.checkgrad(tolerance=self.tolerance))
 def test_ChecKGrads_LCB(self):
     acquisition_lcb = AcquisitionLCB(1)
     acquisition_lcb.set_model(self.model)
     grad_lcb = GradientChecker(
         acquisition_lcb.acquisition_function, acquisition_lcb.d_acquisition_function, self.X_test
     )
     self.assertTrue(grad_lcb.checkgrad(tolerance=self.tolerance))
Beispiel #5
0
    def test_gradient(self, acq_maxvar):
        """Test the gradient function using GPy's GradientChecker.

        Parameters
        ----------
        acq_maxvar : MaxVar
            Acquisition method.

        """
        from GPy.models.gradient_checker import GradientChecker
        n_pts_test = 100
        n_dim_fixture = len(acq_maxvar.model.bounds)

        checker_grad = GradientChecker(
            acq_maxvar.evaluate, acq_maxvar.evaluate_gradient,
            np.random.randn(n_pts_test, n_dim_fixture))

        # The tolerance corresponds to the allowed deviation from the unity of
        # the ratio between analytical and numerical gradients.
        assert checker_grad.checkgrad(tolerance=1e-4)
	def test_ChecKGrads_MPI(self):
		acquisition_mpi = AcquisitionMPI(1)
		acquisition_mpi.set_model(self.model)
		grad_mpi = GradientChecker(acquisition_mpi.acquisition_function,acquisition_mpi.d_acquisition_function,self.X_test)
		self.assertTrue(grad_mpi.checkgrad(tolerance=self.tolerance))
	def test_ChecKGrads_LCB(self):
		acquisition_lcb = AcquisitionLCB(1)
		acquisition_lcb.set_model(self.model)
		grad_lcb = GradientChecker(acquisition_lcb.acquisition_function,acquisition_lcb.d_acquisition_function,self.X_test)
		self.assertTrue(grad_lcb.checkgrad(tolerance=self.tolerance))
	def test_ChecKGrads_LCB(self):
		acquisition_lcb = acquisition_for_test(AcquisitionLCB(self.model,self.feasible_region))
		grad_lcb = GradientChecker(acquisition_lcb.acquisition_function,acquisition_lcb.d_acquisition_function,self.X_test)
		self.assertTrue(grad_lcb.checkgrad(tolerance=self.tolerance))
	def test_ChecKGrads_MPI(self):
		acquisition_mpi = acquisition_for_test(AcquisitionMPI(self.model,self.feasible_region))
		grad_mpi = GradientChecker(acquisition_mpi.acquisition_function,acquisition_mpi.d_acquisition_function,self.X_test)
		self.assertTrue(grad_mpi.checkgrad(tolerance=self.tolerance))