Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sebastian/faster tests #395

Merged
merged 4 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tests/integration/models/gpflux/test_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def test_dgp_model_close_to_actuals(
Ensure that DGP model fits well and predictions are close to actual output values.
"""

dataset_size = 100
num_inducing = 100
batch_size = 100
epochs = 2000
dataset_size = 50
num_inducing = 50
batch_size = 50
epochs = 500

example_data = hartmann_6_dataset_function(dataset_size)

Expand All @@ -51,16 +51,16 @@ def test_dgp_model_close_to_actuals(
model.optimize(example_data)
predicted_means, _ = model.predict(example_data.query_points)

np.testing.assert_allclose(predicted_means, example_data.observations, atol=0.1, rtol=0.2)
np.testing.assert_allclose(predicted_means, example_data.observations, atol=0.2, rtol=0.2)


@random_seed
def test_dgp_model_close_to_simple_implementation(
hartmann_6_dataset_function: Callable[[int], Dataset], depth: int, keras_float: None
) -> None:
dataset_size = 200
num_inducing = 100
batch_size = 100
dataset_size = 50
num_inducing = 50
batch_size = 50
epochs = 500
learning_rate = 0.01

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_bayesian_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def build_model(data: Dataset) -> GaussianProcessRegression:
@pytest.mark.parametrize(
"num_steps, acquisition_rule",
[
(5, DiscreteThompsonSampling(1000, 50)),
(1, DiscreteThompsonSampling(1000, 50)),
],
)
def test_two_layer_dgp_optimizer_finds_minima_of_michalewicz_function(
Expand All @@ -207,7 +207,7 @@ def test_two_layer_dgp_optimizer_finds_minima_of_michalewicz_function(
search_space = Box(MICHALEWICZ_2_MINIMIZER[0] - 0.5, MICHALEWICZ_2_MINIMIZER[0] + 0.5)

def build_model(data: Dataset) -> DeepGaussianProcess:
epochs = int(2e3)
epochs = int(4e2)
batch_size = 100

dgp = two_layer_dgp_model(data.query_points)
Expand All @@ -228,7 +228,7 @@ def scheduler(epoch: int, lr: float) -> float:

return DeepGaussianProcess(model=dgp, optimizer=optimizer, fit_args=fit_args)

initial_query_points = search_space.sample(50)
initial_query_points = search_space.sample_sobol(20)
observer = mk_observer(michalewicz, OBJECTIVE)
initial_data = observer(initial_query_points)
model = build_model(initial_data[OBJECTIVE])
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/models/gpflow/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def test_gaussian_process_regression_optimize(

@random_seed
def test_variational_gaussian_process_predict() -> None:
x_observed = tf.constant(np.arange(100).reshape((-1, 1)), dtype=gpflow.default_float())
x_observed = tf.constant(np.arange(3).reshape((-1, 1)), dtype=gpflow.default_float())
y_observed = _3x_plus_gaussian_noise(x_observed)
model = VariationalGaussianProcess(vgp_model(x_observed, y_observed))
internal_model = model.model
Expand All @@ -455,7 +455,7 @@ def test_variational_gaussian_process_predict() -> None:
internal_model.training_loss_closure(),
internal_model.trainable_variables,
)
x_predict = tf.constant([[50.5]], gpflow.default_float())
x_predict = tf.constant([[1.5]], gpflow.default_float())
mean, variance = model.predict(x_predict)
mean_y, variance_y = model.predict_y(x_predict)

Expand Down
2 changes: 1 addition & 1 deletion tests/util/models/gpflux/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def trieste_deep_gaussian_process(
) -> Tuple[DeepGaussianProcess, Dict[str, Any]]:
dgp = build_vanilla_deep_gp(query_points, num_layers=depth, num_inducing=num_inducing)
if fix_noise:
dgp.likelihood_layer.likelihood.variance.assign(1e-4)
dgp.likelihood_layer.likelihood.variance.assign(1e-5)
set_trainable(dgp.likelihood_layer, False)
optimizer = tf.optimizers.Adam(learning_rate)

Expand Down