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

Doubt regarding the Hamiltonian calculations for RHVAE model. #10

Closed
shikhar2333 opened this issue Feb 10, 2022 · 12 comments
Closed

Doubt regarding the Hamiltonian calculations for RHVAE model. #10

shikhar2333 opened this issue Feb 10, 2022 · 12 comments
Labels
question Further information is requested

Comments

@shikhar2333
Copy link

In the paper, Hamiltonian is defined as follows:

H(z, v) = U(z) + K(v)  = -0.5*log(det(G^-1(z)) + 0.5*v^T*v

But in the code, I see extra terms like addition of a joint probability term and a G inverse multiplied in the term for kinetic energy.
Are these 2 equations equivalent?

@clementchadebec
Copy link
Owner

clementchadebec commented Feb 10, 2022

Hi @shikhar2333 ,

Thank you for opening this issue. Actually, the Hamiltonian you are referring to is the one used to sample from the target distribution given by the inverse of the metric volume element post training and so it is used in the RHVAESampler instead. That is why only 0.5*log(det(G^-1(z)) appears in U(z). However, during training, the authors proposed to target another distribution which is the true posterior p(z|x) using Riemannian HMC and that is why you see those extra terms. For a derivation of the Hamiltonian used during training you can have a look to Eq. 9 page 7 in (https://arxiv.org/abs/2010.11518).

I hope this helps.

@shikhar2333
Copy link
Author

Thanks for your response.
The link that you shared doesn't seem to work for me. Can you tell the paper title?

@clementchadebec
Copy link
Owner

Oops, sorry for that, this one should work https://arxiv.org/abs/2010.11518

@shikhar2333
Copy link
Author

shikhar2333 commented Feb 11, 2022

How do we ensure that \rho gets sampled from N(0, G(z))?

rho = (L @ rho.unsqueeze(-1)).squeeze(-1)

In the code I saw this particular initialization for rho. Is this done because L is the cholesky decomposition for the matrix G?

@clementchadebec
Copy link
Owner

We use the Cholesky decomposition of the metric G = LL^T allowing to sample from multivariate Gaussian distributions. Note that G(z) is a symmetric definite positive matrix

@shikhar2333
Copy link
Author

So are M and G equivalent, since M is also defined as LL^T.

@shikhar2333
Copy link
Author

shikhar2333 commented Feb 12, 2022

Is E[P(x|z)] (where z~q(z|x) and E denotes the expectation value) approximated by MSE/BCE loss in the implementation?
Since maximizing log likelihood of the expectation reduces to minimizing reconstruction error L(recon_x,x)?

@clementchadebec
Copy link
Owner

Yes exactly. The MSE (resp. BCE loss) actually represents the opposite log-likelihood of a constant variance Gaussian distribution (resp. Bernoulli distribution) that are usually chosen for p(x|z) depending on the modeling of your data.

@shikhar2333
Copy link
Author

shikhar2333 commented Feb 12, 2022

Thanks for the confirmation.
On a side note, i was wondering whether any conditional input was required in the VAE when you trained on the MRI data, since the dimensionality of the data would be high because it's a 3D input.
Something similar to a conditional VAE.

@clementchadebec
Copy link
Owner

You're welcome :). Not really, you can down-sample a bit your input data to deal with memory issues for instance but, in theory, the VAE can handle any kind of data regardless of the dimension. If you are referring to the paper, we only down-sampled the data by a factor 2 in each dimension when dealing with 3D MRIs.

@shikhar2333
Copy link
Author

What's the intuition for updating the metric at the end of each epoch?

@clementchadebec
Copy link
Owner

The updated metric is needed during validation.

@clementchadebec clementchadebec added the question Further information is requested label Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants