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

Fix bug in zero mean function and add test #358

Merged

Conversation

Thomas-Christie
Copy link
Contributor

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've formatted the new code by running poetry run pre-commit run --all-files --show-diff-on-failure before committing.
  • I've added tests for new code.
  • I've added docstrings for the new code.

Description

Fixes bug whereby the constant in a zero mean function was able to change from model optimisation.

Issue Number: #330

Comment on lines +64 to +66
kernel = kernel.replace_trainable(
constant=False
) # Prevent kernel from modelling non-zero mean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason we have trainability turned off here?

Comment on lines +69 to +70
likelihood = gpx.Gaussian(num_datapoints=D.n, obs_noise=jnp.array(1e-6))
likelihood = likelihood.replace_trainable(obs_noise=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And trainability turned off here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just turned off trainability in both cases such that if the Zero mean was still trainable, it would be the only part of the model able to be trained (and so no other aspect of the model (such as the kernel) could be used to model the non-zero mean of the data other than the Zero mean function).

Copy link
Member

@daniel-dodd daniel-dodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @Thomas-Christie. This is looking good.

Good idea to test training loop!

Two further tests that I'd be keen to see are (1) doing a tree_flatten of the Zero - check that that the flatten leaves are an empty list []. (2) Check that you can't initialise a different value for the constant during class initialisation (i.e., Zero(constant=...) returns an Error). These would eliminate bugs, if we did any future refactoring! :)

@Thomas-Christie
Copy link
Contributor Author

Good idea @daniel-dodd . I have added the two tests you mentioned.

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.

2 participants