atong01 / conditional-flow-matching

TorchCFM: a Conditional Flow Matching library
https://arxiv.org/abs/2302.00482
MIT License
1.08k stars 85 forks source link

Batch OT sampling of conditional PDFs #120

Open CaioDaumann opened 3 months ago

CaioDaumann commented 3 months ago

Dear experts,

Thank you very much for this nice package! I am trying to use your batch OT version of flow matching to perform the matching between two distributions, but I wonder how the OT mapping should work for conditional distributions.

Suppose I have a function y(x|c) and I want to transport it to z(x|c). When I sample n_events from these distributions, they will have different c values among themselves. How can one perform OT mapping between "events" with different condition values?

I thought of something like this: we split the data into bins of c [0, 0.1, 0.2, ...] where we don't expect the PDFs to change much, and during training, sample only events of y(x|c) and z(x|c) where the events of both are in the same bin.

Does that sound reasonable to you? Or is there a clever and simpler way to do it?

Best, Caio

atong01 commented 3 months ago

Hi @CaioDaumann,

Apologies for the delay. This seems fine to me, and is probably the best I can think of to do with relatively small data.

Did it work? :)

CaioDaumann commented 3 months ago

Hi @atong01 ,

Why do you say "best I can think of to do with relatively small data"? I actually have around 12 million events of both y(x|c) and z(x|c). Do you think there is a better solution for "big data"?

I still haven't had time to try it, but I will do so in the next few days and let you know if it worked.

Thanks for your help!