Closed francesco-vaselli closed 10 months ago
Hi Francesco!
The solution seems reasonable enough to me. This is fairly similar to the solution I used in this notebook https://github.com/atong01/conditional-flow-matching/blob/main/examples/images/conditional_mnist.ipynb
except I wrapped the conditional model to be unconditional before the integration. I think this is slightly easier (if your conditions are constant over time), but this solution should work just fine.
--Alex
Closing this issue has it has been solved.
Dear all, Thanks for the great package!
I am working with some data $x$ following an unknown pdf $p(x|c)$. Here, $c$ is some additional information which we would like to give as input to the model in order to learn the correct correlations and dependencies between the target $x$ and $c$. In this way, when transforming the latent noise space $u$, we can get different $x$ according to the input $c$ (simplest example: get only one half of the two moons dataset based on 0/1 input flag).
I did implement a solution for this use case. I would like to get your feedback on whether this is a reasonable solution, or something has already been done to address this type of problem.
The main steps are as follows:
context
), and we create a model wrapper which evolves the data with the base model and assign 0s to the derivatives of the context (in this way it remains constant through all the trajectory).context
input in the forward callcontext
for the model wrapper to work directly with ODE solvers such as torchdiffeqThe code is as follows:
We define the base model to take an additional input (
context
), and we create a model wrapper which evolves the data with the base model and assign 0s to the derivatives of the context (in this way it remains constant through all the trajectory).Then in the training loop we do something like:
While for sampling new data from noise:
This approach works perfectly for our use case. Do you think it's reasonable and efficient enough?
I would appreciate any guidance whatsoever, and if the solution seems interesting, I would be more than happy to work on a pull request!
Best regards Francesco