benchmark_VAE icon indicating copy to clipboard operation
benchmark_VAE copied to clipboard

Posterior Sampling for PVAE

Open ErfanMowlaei opened this issue 1 year ago • 8 comments

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.

ErfanMowlaei avatar Dec 05 '23 17:12 ErfanMowlaei

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

clementchadebec avatar Dec 06 '23 06:12 clementchadebec

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?

ErfanMowlaei avatar Dec 06 '23 21:12 ErfanMowlaei

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

clementchadebec avatar Dec 07 '23 18:12 clementchadebec

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!

ErfanMowlaei avatar Dec 08 '23 07:12 ErfanMowlaei

Hi @ErfanMowlaei ,

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

Best,

Clément

clementchadebec avatar Dec 08 '23 07:12 clementchadebec

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 avatar Dec 22 '23 05:12 ErfanMowlaei

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 :)

clementchadebec avatar Jan 03 '24 22:01 clementchadebec

@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.

ErfanMowlaei avatar Jan 04 '24 15:01 ErfanMowlaei