BayesFlow
BayesFlow copied to clipboard
Add conditional optimal transport for flow matching
This pull request introduces significant improvements to the optimal transport functionality, with a focus on supporting partial and conditional optimal transport in both the Sinkhorn and Log-Sinkhorn algorithms.
- Added support for partial optimal transport and conditional optimal transport in both Sinkhorn and Log-Sinkhorn algorithms. Both can in principle learn a better transport map for conditional flow matching.
- Refactored the Sinkhorn and Log-Sinkhorn methods to improve computational efficiency (using the dual optimization problem).
- Updated the
optimal_transportAPI to accept and correctly propagateconditions, and to return resampled conditions and assignments for both balanced and unbalanced (partial/conditional) settings. - Changed default configuration values and documentation to reflect new options and recommended settings for conditional optimal transport.
- Refactored code in
flow_matching.pyto handle new outputs from the optimal transport functions and to properly resample conditions when provided.
Codecov Report
:x: Patch coverage is 97.00599% with 5 lines in your changes missing coverage. Please review.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...sflow/utils/optimal_transport/optimal_transport.py | 100.00% <100.00%> (ø) |
|
| bayesflow/utils/optimal_transport/ot_utils.py | 100.00% <100.00%> (ø) |
|
| bayesflow/networks/flow_matching/flow_matching.py | 94.35% <0.00%> (+1.49%) |
:arrow_up: |
| bayesflow/utils/optimal_transport/log_sinkhorn.py | 96.61% <95.34%> (-3.39%) |
:arrow_down: |
| bayesflow/utils/optimal_transport/sinkhorn.py | 96.87% <95.65%> (-3.13%) |
:arrow_down: |