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

Check treatment of scale matrix vs covariance matrix in sampling procedure #19

Open
cpmpercussion opened this issue Oct 30, 2019 · 1 comment

Comments

@cpmpercussion
Copy link
Owner

There could be an issue with sampling due to (my) confusion about standard deviation and variance.

The samples are drawn using numpy like so (documentation) (line 238 of __init__.py)

sample = np.random.multivariate_normal(mus_vector, cov_matrix, 1)

But the output from the mixture density layer are treated as scale variables in tfp.distributions.MultivariateNormalDiag. This notes that:

covariance = scale @ scale.T

Thus, it seems we should have been squaring the cov_matrix before putting it into the multivariate normal sampling procedure. This could explain why we end up having to scale down the sigma variable so much in real-world applications.

A todo here is to get a definite answer and do some test to try out what's going on.

@cpmpercussion cpmpercussion changed the title Check sampling procedure Check treatment of scale matrix vs covariance matrix in sampling procedure Oct 30, 2019
@cpmpercussion
Copy link
Owner Author

it seems to me that the scale vector should have been squared before using as a covariance matrix, so this is now the current behaviour.

It remains to write a test (going across tensorflow probability and numpy) that a tfd scale vector is actually going to produce the correct distributions.

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

No branches or pull requests

1 participant