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

Multi Latent Likelihoods using new quadrature Likelihoods #1559

Merged
merged 58 commits into from
Sep 15, 2020

Conversation

vdutor
Copy link
Contributor

@vdutor vdutor commented Sep 10, 2020

This PR adds MultiLatent likelihoods, of which HeteroskedasticTFPConditional is an example, on top of the newly refactored QuadratureLikelihoods (PR #1549).

A notebook (courtesy of @st-- in PR #1455 ) and tests are added for documentation purposes.

st-- and others added 30 commits April 1, 2020 09:58
* fixes

* typo fix; reshaping fix

* notebook showing how to use HeteroskedasticTFPDistribution likelihood

* converting to .pct.py format

* removed .ipynb

* better descriptions

* black auto-formatting

Co-authored-by: Gustavo Carvalho <gustavo.carvalho@delfosim.com>
These tests ensure that heteroskedastic likelihood with a constant variance, will give the same results as a Gaussian likelihood with the same variance.
Co-authored-by: Vincent Dutordoir <dutordoirv@gmail.com>
@vdutor vdutor changed the base branch from gustavocmv/quadrature-likelihood to develop September 15, 2020 15:00
@vdutor vdutor marked this pull request as ready for review September 15, 2020 15:00
Copy link
Contributor

@gustavocmv gustavocmv left a comment

Choose a reason for hiding this comment

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

Looks good, ready to merge.


@property
def quadrature(self):
if self._quadrature is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a stylistic point, others may disagree, but I find this sort of precondition checking easier to read if you invert the if statements so that the condition and what happens if it fails are grouped together, e.g.

`

if self._quadrature is None:
return self._quadrature

if self.latent_dim is None:
raise Exception(
"latent_dim not specified. "
"Either set likelihood.latent_dim directly or "
"call a method which passes data to have it inferred."
)

with tf.init_scope():
self._quadrature = NDiagGHQuadrature(self.latent_dim, self.num_gauss_hermite_points)

`

That way you end up with fewer levels of nesting, and it's easier to separate the precondition checking from what the method really does.

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.

None yet

6 participants