-
Notifications
You must be signed in to change notification settings - Fork 42
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
Encoded DeepGPs. #873
Merged
Merged
Encoded DeepGPs. #873
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e90f91c
Encoded DeepGPs.
avullo 97647cb
Test class adhere to encoded interface.
avullo d429e45
Reformatting.
avullo c3c2302
Use encoder with trajectory sampling.
avullo 29d55e8
Avoid runtime error.
avullo 89736e8
Unused import.
avullo 6b23bf7
Correct reference to encode function.
avullo eb2ed89
Correct another runtime instance error.
avullo 1cf1c28
Unused import.
avullo 2294bdd
Yet another runtime error.
avullo dbe623b
Yet another unused import.
avullo 9e0ea23
Encode the reparam sampler.
avullo 03d0e0f
Test GPflux predictor categorical predict.
avullo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ def __init__(self, sample_size: int, model: GPfluxPredictor): | |
) | ||
for _ in range(len(self._model_gpflux.f_layers)) | ||
] | ||
self._encode = lambda x: model.encode(x) | ||
|
||
@property | ||
def _model_gpflux(self) -> tf.Module: | ||
|
@@ -96,7 +97,9 @@ def sample(self, at: TensorType, *, jitter: float = DEFAULTS.JITTER) -> TensorTy | |
tf.debugging.assert_shapes([(at, [..., 1, None])]) | ||
tf.debugging.assert_greater_equal(jitter, 0.0) | ||
|
||
samples = tf.repeat(at[..., None, :, :], self._sample_size, axis=-3) # [..., S, 1, D] | ||
samples = tf.repeat( | ||
self._encode(at[..., None, :, :]), self._sample_size, axis=-3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason not to encode first thing? at = self._encode(at)
samples = tf.repeat(at[..., None, :, :], self._sample_size, axis=-3) # [..., S, 1, D] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mainly compactness. |
||
) # [..., S, 1, D] | ||
for i, layer in enumerate(self._model_gpflux.f_layers): | ||
if isinstance(layer, LatentVariableLayer): | ||
if not self._initialized: | ||
|
@@ -477,6 +480,8 @@ def __init__(self, model: GPfluxPredictor, num_features: int): | |
for i in range(len(model.model_gpflux.f_layers)) | ||
] | ||
|
||
self._encode = lambda x: model.encode(x) | ||
|
||
@tf.function | ||
def __call__(self, x: TensorType) -> TensorType: | ||
""" | ||
|
@@ -486,6 +491,7 @@ def __call__(self, x: TensorType) -> TensorType: | |
the batch dimension, and `D` is the input dimensionality. | ||
:return: Trajectory samples with shape `[N, B, L]`, where `L` is the number of outputs. | ||
""" | ||
x = self._encode(x) | ||
for layer in self._sampling_layers: | ||
x = layer(x) | ||
return x | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of curiosity, does the following work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I think it does.