Skip to content

DSM_

DSM_(dist, times, net, L=5, n_epochs=5000, bs=None, adaptive_weights=0, lr=0.0005, scheduler_factory=None, kernel='gaussian', verbose=True, generator=None)

Train a score network with denoising score matching.

Parameters:

  • dist (list of torch.Tensor, length nsnaps) –

    dist[k] has shape (n_k, ndim) and must already be float32 on the same device as net.

  • times (torch.Tensor of shape (nsnaps,)) –

    Snapshot times as float32 on the same device as net.

  • net (Module) –

    Score network that accepts inputs with last dimension ndim + 2.

  • L (int, default: 5 ) –

    Number of noise levels.

  • n_epochs (int, default: 5000 ) –

    Number of optimization epochs.

  • bs (int or None, default: None ) –

    Mini-batch size over sample dimension. If None, uses all samples.

  • adaptive_weights (int, default: 0 ) –

    If set to 1, enable adaptive per-time weighting.

  • lr (float, default: 5e-4 ) –

    Learning rate.

  • scheduler_factory (callable or None, default: None ) –

    Callable (optimizer) -> scheduler. If None, uses MultiStepLR with milestones=[2500, 6500, 8500], gamma=0.1.

  • kernel ((gaussian, laplace), default: "gaussian" ) –

    Noise kernel q(x_noisy | x). The learned score is that of the data convolved with the kernel, so it inherits the kernel's tails: Gaussian tails (score growing linearly away from the data) or exponential tails (score tending to -1 / scale). The noise levels are the Gaussian standard deviation or the Laplace scale.

  • verbose (bool, default: True ) –

    If True, show progress bars and diagnostics.

Returns:

  • net ( Module ) –

    Trained score network.

  • loss_hist ( list of float ) –

    Epoch-wise training loss values.

  • sigma ( torch.Tensor of shape (L,) ) –

    Noise schedule used during training.