Flow matching with Lipman et al. formulation #16
-
Hi there, Thanks for the amazing work on this package 🔥 I am working on an implementation of (unconditional) flow matching using I had a look at the implementation of (conditional) flow matching posterior estimation (FMPE) in Lampe Lines 141 to 143 in 3e88c8e and noticed that it is using a different notation and a different flow matching objective than in the original Lipman et al. paper: In the initial paper by Lipman et al., the optimal transport flow matching formulation implicitly assumes a Gaussian source In the Lampe implementation, two things are different:
And this is where my problem comes in: The setup with swapped Lines 95 to 103 in 3e88c8e However, if I want to implement the original Lipman et al. formulation, this setup does not work because It could well be I am missing something and this is trivial, but: How can I setup the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello @janfb, I have split my answer into two parts. Tell me if anything is not clear! Also you might want to check this 100 lines of code implementation of flow matching. Flow matching objectiveI am not sure to understand the notations of the screenshots. However, as you note, we reverse the time axis ( Doing so, we get and the objective In addition, we assume that
Free-form Jacobian transformActually, It defines a transformation that is the integration of a vector field Hence, if you have a network that approximates a flow-matching vector field transform = FreeFormJacobianTransform(
f=lambda t, x: network(t, x),
t0=x.new_tensor(1.0), # t_0 = 1 /!\
t1=x.new_tensor(0.0),
phi=network.parameters(),
) By the way, to inverse this transformation you can simply swap
|
Beta Was this translation helpful? Give feedback.
-
Hello @francois-rozet thanks a lot for the fast response and for sharing your code snippet! Flow matching objectiveOh wow, I see it now. Interesting that your assumptions then result in a formulation that very much resembles the independent source flow matching objective from Tong et al.. (Regarding It's likely that I am again missing something, but in your code snippet linked above, it seems to me that in line 88 u = z - (1 - 1e-4) * x ? Free-form Jacobian transformYes, that makes sense - thanks! |
Beta Was this translation helpful? Give feedback.
There is a mistake in the here-above justification! Sorry for the confusion; this "time inversion" is really messing with my head 😅
The CFM loss is actually (see Eq. 14)
where
When we reverse the time ($t \to 1 - t$ and $x_0 \leftrightarrow x_1$ ), we get
and
So in my previous comment, the objective should be