torchcell.losses
Loss functions. The package exports ListMLELoss, a listwise ranking loss, and DCellLoss, the root plus subsystem loss of the DCell model. The remaining modules (multi_dim_nan_tolerant, distributional, mle_wasserstein, point_dist_graph_reg and others) are imported by module path from the experiment training scripts and are not re-exported. Every class below is listed under the module that defines it.
dango
DANGO loss with epoch-scheduled weighting of reconstruction vs interaction loss.
Classes
Abstract base class for DANGO loss schedulers. |
|
Schedule that uses reconstruction loss only before transition_epoch, then switches to interaction loss only. |
|
Schedule that linearly transitions from reconstruction-focused to uniform weighting. |
|
Schedule that linearly transitions from reconstruction-focused to interaction-focused. |
|
Combined loss for the DANGO model with dynamic weighting between reconstruction loss and interaction loss. |
dcell
Loss for the DCell model: root MSE plus optional subsystem auxiliary losses.
Classes
Loss function for the DCell model (Ma et al. 2018). |
diffusion_loss
Strict diffusion loss with optional explicit x0 supervision.
Classes
Strict diffusion loss for conditional decoders. |
distributional
Distributional decoder heads + proper-scoring-rule losses for the multitask CGT.
Classes
Pluggable distributional readout: interpret a head's raw params, score them, pool. |
Functions
Closed-form CRPS of a Gaussian \(\mathcal N(\mu,\sigma)\) vs observations. |
|
Closed-form CRPS of a Laplace \(\mathrm{Lap}(\mu,b)\) vs observations. |
|
Gaussian negative log-likelihood, WITHOUT the constant term. |
|
Monte-Carlo energy score of a low-rank-plus-diagonal Gaussian, per row. |
|
Pinball (quantile / check) loss for a set of predicted quantiles. |
|
Mean of |
|
Probability integral transform -- ONE calibration diagnostic for every mode. |
|
Empirical coverage of the central |
|
Kolmogorov-Smirnov distance between the PIT distribution and |
|
Params-per-feature for a config |
|
Build a |
isomorphic_cell_loss
Isomorphic cell losses combining MSE, distribution, and SupCR terms.
Classes
Weighted sum of MSE, distribution, and SupCR cell losses. |
|
IC loss with learnable per-task standard deviations (heteroscedastic). |
list_mle
ListMLE listwise ranking loss for ordered prediction tasks.
Classes
Listwise Maximum Likelihood Estimation ranking loss. |
logcosh
Log-cosh regression loss module.
Classes
Log-cosh loss: a smooth, outlier-robust alternative to MSE. |
mle_dist_supcr
Combined MLE, distribution, and supervised contrastive loss with buffering.
Classes
Manages adaptive weighting for buffer contributions during training. |
|
Manages temperature scheduling for SupCR loss. |
|
Enhanced distribution loss with circular buffer for small batch training. |
|
Enhanced SupCR loss with circular buffer for small batch training. |
|
Composite loss combining MSE, distribution matching, and SupCR. |
mle_wasserstein
Composite MSE + Wasserstein + SupCR loss with buffers and DDP gathering.
Classes
Manages adaptive weighting for buffer contributions during training. |
|
Manages temperature scheduling for SupCR loss. |
|
Weighted Wasserstein distance loss for multi-dimensional outputs. |
|
Enhanced Wasserstein loss with circular buffer for small batch training. |
|
Enhanced SupCR loss with circular buffer for small batch training. |
|
Composite MSE + Wasserstein + SupCR loss. |
multi_dim_nan_tolerant
NaN-tolerant multi-dimensional loss functions for cell-state regression.
Classes
Supervised Contrastive Regression (SupCR) loss over multiple target dimensions. |
|
SupCR loss with per-dimension weights for cell-state embeddings. |
|
Per-dimension L1 loss that ignores NaN targets. |
|
Per-dimension Huber loss that ignores NaN targets. |
|
Per-dimension log-cosh loss that ignores NaN targets. |
|
Per-dimension MSE loss with optional normalized dimension weights. |
|
Per-dimension MSE loss that ignores NaN targets. |
|
Quantile regression loss that handles NaN values. |
|
Fast differentiable sorting following the original paper implementation. |
|
Distribution-matching (DistLoss) loss using KDE and differentiable sorting. |
|
Dispatch to a NaN-tolerant regression loss and apply per-dimension weights. |
|
Multi-task cross-entropy loss that ignores NaN targets per task. |
|
Cross-entropy loss combining per-task losses with dimension weights. |
|
Parameter that ensures values are monotonically increasing via cumulative softplus. |
|
Multi-task ordinal cross-entropy loss with learnable monotonic thresholds. |
|
Combined ordinal classification loss with dimension-wise weighting. |
|
Entropy regularization loss that works with both soft and one-hot categorical targets. |
|
Combine MSE loss with entropy regularization, tracking per-dimension losses. |
Functions
Solve isotonic regression using the PAV (Pool Adjacent Violators) algorithm. |
|
Fast differentiable sorting that follows the original paper's implementation. |
point_dist_graph_reg
Composite point + distribution + graph-regularization loss for the cell transformer.
Classes
Modular composite loss for Cell Graph Transformer combining: 1. |