def test_uncertainty_sampling_shapes(model, model_with_density): # test both with Lebesgue measure and with a probability measure because the gradients are computed differently x = np.array([[-1, 1], [0, 0], [-2, 0.1]]) aq = UncertaintySampling(model) aq_with_density = UncertaintySampling(model_with_density) # value res = aq.evaluate(x) assert res.shape == (3, 1) # gradient res = aq.evaluate_with_gradients(x) assert res[0].shape == (3, 1) assert res[1].shape == (3, 2) # value res = aq_with_density.evaluate(x) assert res.shape == (3, 1) # gradient res = aq_with_density.evaluate_with_gradients(x) assert res[0].shape == (3, 1) assert res[1].shape == (3, 2)
def uncertainty_sampling(model_test_list_fixture): return UncertaintySampling(model_test_list_fixture)
def uncertainty_sampling_acquisition(vanilla_bq_model): return UncertaintySampling(vanilla_bq_model)
def test_uncertainty_sampling_gradients(model, model_with_density): aq = UncertaintySampling(model) aq_with_density = UncertaintySampling(model_with_density) x = np.array([[-2.5, 1.5]]) _check_grad(aq, x) _check_grad(aq_with_density, x)