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

Add constant_constraint to ConstantMean #2082

Merged
merged 2 commits into from
Aug 8, 2022
Merged

Conversation

gpleiss
Copy link
Member

@gpleiss gpleiss commented Jul 27, 2022

Previously, ConstantMean only supported a prior on the constant (not a constraint). This PR adds a constant_constraint kwarg to ConstantMean.

Backwards compatibility
There are two non-backwards compatible changes to ConstantMean, though there is a state_dict hook to ensure that previous state dicts can be loaded:

  • The constant parameter is renamed to raw_constant.
  • The shape of raw_constant is now *batch_shape, rather than *batch_shape x 1.

[Fixes #2074]

Comment on lines +41 to +45
:type constant_prior: ~gpytorch.priors.Prior, optional
:param constant_constraint: Constraint for constant parameter :math:`C`.
:type constant_constraint: ~gpytorch.priors.Interval, optional
:param batch_shape: The batch shape of the learned constant(s) (default: []).
:type batch_shape: torch.Size, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

consistency nit

Suggested change
:type constant_prior: ~gpytorch.priors.Prior, optional
:param constant_constraint: Constraint for constant parameter :math:`C`.
:type constant_constraint: ~gpytorch.priors.Interval, optional
:param batch_shape: The batch shape of the learned constant(s) (default: []).
:type batch_shape: torch.Size, optional
:type constant_prior: ~gpytorch.priors.Prior, optional.
:param constant_constraint: Constraint for constant parameter :math:`C`.
:type constant_constraint: ~gpytorch.priors.Interval, optional.
:param batch_shape: The batch shape of the learned constant(s) (default: []).
:type batch_shape: torch.Size, optional.

:param batch_shape: The batch shape of the learned constant(s) (default: []).
:type batch_shape: torch.Size, optional

:var torch.Tensor constant: :math:`C` parameter
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
:var torch.Tensor constant: :math:`C` parameter
:var torch.Tensor constant: :math:`C` parameter.

Comment on lines +68 to +73
else: # Weird edge case where someone set both `prior` and `constant_prior`
warnings.warn(
"You have set both the `constant_prior` and the deprecated `prior` arguments for ConstantMean. "
"`prior` is deprecated, and will be ignored.",
DeprecationWarning,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is weird enough that we may just want to throw an error here?

@gpleiss gpleiss enabled auto-merge (squash) August 8, 2022 21:13
@gpleiss gpleiss merged commit a91db39 into master Aug 8, 2022
Balandat added a commit to Balandat/botorch that referenced this pull request Aug 9, 2022
cornellius-gp/gpytorch#2082 changed the shape of the mean constant (and did some other things). These changes fix the resulting unit test breakages.
Balandat added a commit to Balandat/Ax that referenced this pull request Aug 9, 2022
cornellius-gp/gpytorch#2082 changed the shape of the mean constant (and did some other things). These changes fix the resulting unit test breakages.
Balandat added a commit to Balandat/Ax that referenced this pull request Aug 9, 2022
Summary:
cornellius-gp/gpytorch#2082 changed the shape of the mean constant (and did some other things). These changes fix the resulting unit test breakages.

This requires the botorch change pytorch/botorch#1343

Pull Request resolved: facebook#1055

Reviewed By: lena-kashtelyan

Differential Revision: D38527699

Pulled By: Balandat

fbshipit-source-id: 86a9a9fb272cebb923e2fafc76fd44624f1069d0
facebook-github-bot pushed a commit to pytorch/botorch that referenced this pull request Aug 9, 2022
Summary:
cornellius-gp/gpytorch#2082 changed the shape of the mean constant (and did some other things). These changes fix the resulting unit test breakages.

Pull Request resolved: #1343

Reviewed By: saitcakmak

Differential Revision: D38527688

Pulled By: Balandat

fbshipit-source-id: a9878b3ff5d045b18c3330f4e0707a3ee4be2553
facebook-github-bot pushed a commit to facebook/Ax that referenced this pull request Aug 9, 2022
Summary:
cornellius-gp/gpytorch#2082 changed the shape of the mean constant (and did some other things). These changes fix the resulting unit test breakages.

This requires the botorch change pytorch/botorch#1343

Pull Request resolved: #1055

Reviewed By: lena-kashtelyan

Differential Revision: D38527699

Pulled By: Balandat

fbshipit-source-id: e2c13d78d4ce25e35152a0e19a23e2b107627d37
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.

[Question] Setting a constraint for the ConstantMean()
2 participants