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

Sample from constrained kernel params before model fitting #297

Merged

Conversation

henrymoss
Copy link
Collaborator

This PR allows our kernel initialization routine for GPR models to sample kernel parameters with (Sigmoid) constraints. Previously, this routine only sampled parameters with hyper-priors.

Our sampling strategy follows the following hierarchy

  1. If a param is constrained with a sigmoid bijector then we sample from its constrained domain (ignoring its priors if it has them).
  2. If a param is not constrained but has a prior then we sample from the prior
  3. otherwise we do not sample the param and fix its values to its initialization.

This new change will be detailed in my imminent notebook overhaul.

@henrymoss
Copy link
Collaborator Author

henrymoss commented Jul 15, 2021

To use this in practice, do something like
upper = (search_space.upper-search_space.lower)*tf.math.sqrt(tf.cast(len(search_space.upper),dtype=tf.float64))
lower = upper / 100

model.kernel.lengthscales = gpflow.Parameter(
        model.kernel.lengthscales, transform=tfp.bijectors.Sigmoid(low=lower, high=upper)
    )

when defining your model

trieste/models/model_interfaces.py Outdated Show resolved Hide resolved
tests/unit/models/test_model_interfaces.py Show resolved Hide resolved
@henrymoss henrymoss merged commit 6319650 into secondmind-labs:develop Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants