-
Notifications
You must be signed in to change notification settings - Fork 46
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
Refactor GIBBON to avoid retracing #349
Refactor GIBBON to avoid retracing #349
Conversation
tf.debugging.assert_rank(samples, 2) | ||
tf.debugging.assert_positive(len(samples)) | ||
self._samples.assign(samples) |
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.
I've added in a few of these extra asserts. Was there a reason not to have these before? I guess they will need unit testing now
def _get_min_value_samples( | ||
model: ProbabilisticModel, | ||
dataset: Dataset, | ||
sampled_points: TensorType, | ||
num_samples: int, | ||
use_thompson: bool, | ||
num_fourier_features: Optional[int] = None, | ||
) -> TensorType: | ||
|
||
if not use_thompson: # use Gumbel sampler | ||
sampler: ThompsonSampler = GumbelSampler(num_samples, model) | ||
elif num_fourier_features is not None: # use approximate Thompson sampler | ||
sampler = RandomFourierFeatureThompsonSampler( | ||
num_samples, | ||
model, | ||
dataset, | ||
sample_min_value=True, | ||
num_features=num_fourier_features, | ||
) | ||
else: # use exact Thompson sampler | ||
sampler = ExactThompsonSampler(num_samples, model, sample_min_value=True) | ||
|
||
return sampler.sample(sampled_points) |
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.
This needs unit testing
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.
These is a private function so wouldn't normally be unit tested directly. The code paths are tested instead via MinValueEntropySearch and GIBBON.
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.
LGTM!
No description provided.