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

Example on computing logprob with the model #157

Open
fountaindive opened this issue Jan 13, 2025 · 3 comments
Open

Example on computing logprob with the model #157

fountaindive opened this issue Jan 13, 2025 · 3 comments

Comments

@fountaindive
Copy link

Hi,

First of all this work is super impressive and thanks for doing it!

I asked about computing the density of a sample here. I was able to run this example notebook however, I couldn't figure out how to use the model in the following way

logprob = model.logprob(X)

For example, it would be really useful to be able evaluate the logprob of the model on any input sample if that makes sense!

This might be me not fully understanding the method but to evaluate the logprob do you have run the ODE solver for a sample going from the prior space to the target space? Or can you take a sample already in the target space and compute the logprob?

Thanks!

@atong01
Copy link
Owner

atong01 commented Jan 13, 2025

Yep, definitely makes sense! Should probably add this to the library. I'll see if anyone is interested in doing that :)

The notebook actually gives a way to do this for an arbitrary sample.

Training a CNF essentially calculates the likelihood under the model for random samples of the dataset, and maximizes this.

You can use the same logic to calculate the likelihood under the model for any given point. Essentially you have to run the ODE solver backwards from the target space to the prior space, and calculate the change in likelihood along that path. So you can take the CNF wrapper in that notebook and the loss for the CNF

Hope that helps!

--Alex

@fountaindive
Copy link
Author

Cool! That makes sense thanks!

Perhaps a quick question on how you handle more than 2 dimensions specifically for tabular data, is that supported?

Cheers!

@atong01
Copy link
Owner

atong01 commented Jan 13, 2025

This should work fine. Currently the model takes in 2 + 1 dimensions (1 dimension for time) and 2 outputs controlled by the dim parameter. If you change this or make a similar model structure it should 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