PFM_
PFM_(dist, times, net, interp=None, paths=None, growth_model=None, precomputed_traj=None, bs=512, fac=4, n_epochs=2000, lr=0.001, alpha_ann=0.5, scheduler_factory=None, n_rounds=1, n_epochs_round=None, push_steps=8, history=None, verbose=True, generator=None)
Train drift and optional growth models with weighted flow matching.
Parameters:
-
dist(list of torch.Tensor) –Snapshot list where
dist[k]has shape(n_k, ndim). -
times(torch.Tensor of shape (n_snaps,)) –Snapshot times.
-
net(Module) –Drift model receiving
(x, t)as input. -
interp(object or None, default:None) –Interpolant implementing
fitandpredict. IfNone,ChebyshevInterpolant()is used. -
paths(PathEnsemble or None, default:None) –Path ensemble providing the trajectories (
fit(dist, push)thensample()). IfNone,ExactOT(). -
growth_model(Module or None, default:None) –Optional growth model receiving spatial coordinates only.
-
precomputed_traj(Tensor or None, default:None) –Optional precomputed OT trajectories with shape
(ntraj, n_snaps, ndim), used instead ofpaths. IfNone, trajectories are sampled frompaths. -
bs(int or None, default:512) –Number of sampled trajectories per optimization step. If
None, use all sampled trajectories. -
fac(int, default:4) –Number of interpolation nodes per snapshot interval multiplier.
-
n_epochs(int, default:2000) –Number of optimizer iterations.
-
lr(float, default:1e-3) –Learning rate for Adam optimizer.
-
alpha_ann(float, default:0.5) –Exponential averaging factor for adaptive mass-balance weighting.
-
scheduler_factory(callable or None, default:None) –Callable
(optimizer) -> scheduler. IfNone, usesMultiStepLRwithmilestones=[1000, 1500, 5000], gamma=0.1. -
n_rounds(int, default:1) –Number of rounds of the iterated coupling. Round 1 builds the paths without a model; every further round builds them again with the current model as reference dynamics (each interval's source pushed by the model's flow, see
pfi.flow.paths) and retrains the model, warm-started, forn_epochsepochs with a fresh optimizer and scheduler.1: no iteration (original behaviour). -
n_epochs_round(int or None, default:None) –Optimizer iterations of every round after the first;
None:n_epochs. -
push_steps(int, default:8) –Runge-Kutta 4 steps per snapshot interval when pushing with the model.
-
history(list or None, default:None) –If a list, receives one dict per round:
round,change(relative change of the model's velocity on the round's path nodes during the round's training, at most 5000 nodes) andloss(last loss). -
verbose(bool, default:True) –If
True, display progress bars. -
generator(Generator or None, default:None) –Optional RNG for reproducible OT sampling and mini-batching.
Returns:
-
drift_net(Module) –Trained drift model.
-
growth_model(Module or None) –Trained growth model, or
None. -
loss_hist(list of float) –Optimization loss history.