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

Posterior Sampling for PVAE #120

Open
ErfanMowlaei opened this issue Dec 5, 2023 · 8 comments
Open

Posterior Sampling for PVAE #120

ErfanMowlaei opened this issue Dec 5, 2023 · 8 comments

Comments

@ErfanMowlaei
Copy link

I was wondering if it is possible for you to add posterior sampling to PVAE model. The problem with prior sampling is that the embedding space could be sparse and in this case prior sampling would do terrible.

@clementchadebec
Copy link
Owner

Hi @ErfanMowlaei ,

Thank you for opening this issue.
Just to be sure I understand correctly what you have in mind by "posterior sampling". Do you expect to generate new latent codes using the aggregated posterior distribution? the expression of which is given below

Screenshot_20231206_071825_Chrome~2.jpg

@ErfanMowlaei
Copy link
Author

Hi @clementchadebec ,

I appreciate your help.

That is correct and what I am looking for. Also I noticed that the sampler for PVAE has learnable parameters for mu and log_var. However, the number of parameters for mu equals to the number of latent dimensions, but for log_var there is only one parameter. Is this a bug?

@clementchadebec
Copy link
Owner

Hi @ErfanMowlaei,

Ok, in such a case you can use the samplers provided in the library such as the GaussianMixtureSampler or MAFSampler and use them as explained in this section. They will basically fit a distribution on the latent codes empirical distribution (i.e. the aggregated posterior) and so give you a fairly good approximation of it.

As to the prior parameters, log_var is basically only a one-dimensional variable in this case since the prior is either a Riemannian Gaussian (which has a scalar dispersion parameter see Eq. 1 of the paper) or a Wrapped Gaussian distribution, the covariance of which is assumed to be proportional to the Identity matrix (as per Alg. 1 of the same paper).

I hope this helps.

Best,

Clément

@ErfanMowlaei
Copy link
Author

Hi @clementchadebec ,

Thank you very much, it was my bad for not carefully studying the library. Well for our project GaussianMixtureSampler made a huge difference and made it much better! Thank you for the suggestion and also explanation of the latent space!

@clementchadebec
Copy link
Owner

Hi @ErfanMowlaei ,

No worries! I am happy to see that this improved your results :)

Best,

Clément

@ErfanMowlaei
Copy link
Author

Hi @clementchadebec ,

As good as GaussianMixtureSampler is, it is using an euclidean geometry and therefore we have to use lots of components to get some decent results, which might not be the best we can get out of the trained model. I was wondering if instead of sklearn's GMM you could use geomstats to make it possible to use the right geometry for the sampler.

@ErfanMowlaei ErfanMowlaei reopened this Dec 22, 2023
@clementchadebec
Copy link
Owner

Hi @ErfanMowlaei ,
Sorry for the late reply. This is is indeed a great idea. However, this would also require a bit of work to create a new sampler relying on geomstats. I will have a look at this function and especially the RiemannianEM to see if this can be included in the lib. In any case, if you have any suggestions regarding the implementation do not hesitate to share them with me or open a PR if you want :)

@ErfanMowlaei
Copy link
Author

@clementchadebec
No problem at all, and happy new year! I appreciate your efforts. I'll try to see if I can assemble a sampler for this case using some code I found (since RiemannianEM does not provide a sampling function). I'll share the code if I can get it to work.

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

2 participants