Loss Functions

53 public types in this namespace, organized by kind.

Models & Types (52)

Type Summary
ABINetMultiTaskLoss<T> ABINet’s multi-task objective: the weighted sum of the vision, language and fusion losses.
APNet2GeneratorLoss<T> APNet / APNet2’s generator objective: amplitude-spectrum loss, anti-wrapping phase loss and reconstructed-STFT loss.
AdversarialLoss<T> Adversarial (GAN) loss driven by a real discriminator, computed on the autodiff tape.
BinaryCrossEntropyLoss<T> Implements the Binary Cross Entropy loss function for binary classification problems.
BinaryCrossEntropyWithLogitsLoss<T> Implements Binary Cross-Entropy loss that accepts raw logits (not probabilities).
BornRuleMseLoss<T> Mean-squared error measured in probability space for models whose final layer emits quantum amplitudes: loss = mean((predicted² − target)²).
CTCLoss<T> Implements the Connectionist Temporal Classification (CTC) loss function for sequence-to-sequence learning.
CategoricalCrossEntropyLoss<T> Implements the Categorical Cross Entropy loss function for multi-class classification.
CharbonnierLoss<T> Implements the Charbonnier loss function, a smooth approximation of L1 loss.
CompositeLossWithLogits<T> Applies a sigmoid to raw logits and then evaluates a weighted composite probability loss.
CompositeLoss<T> A weighted sum of several loss functions: L = sum_i w_i * L_i.
ContrastiveLoss<T> Implements the Contrastive Loss function for learning similarity metrics.
CosineSimilarityLoss<T> Implements the Cosine Similarity Loss between two vectors.
CrossEntropyLoss<T> Implements the Cross Entropy loss function for multi-class classification problems.
CrossEntropyWithLogitsLoss<T> Implements Cross-Entropy loss that accepts raw logits (not probabilities).
DiceLoss<T> Implements the Dice loss function, commonly used for image segmentation tasks.
ElasticNetLoss<T> Implements the Elastic Net Loss function, which combines Mean Squared Error with L1 and L2 regularization.
ExponentialLoss<T> Implements the Exponential Loss function, commonly used in boosting algorithms.
FactorVAEObjective<T> FactorVAE’s training objective: return reconstruction plus the KL divergence between the posterior and prior factor distributions.
FlowLoss<T> Optical-flow consistency loss: penalizes a reconstruction whose MOTION differs from the ground truth’s motion, even where individual frames already match.
FocalLoss<T> Implements the Focal Loss function, which gives more weight to hard-to-classify examples.
HingeLoss<T> Implements the Hinge loss function commonly used in support vector machines.
HuberLoss<T> Implements the Huber loss function, which combines properties of both MSE and MAE.
JaccardLoss<T> Implements the Jaccard loss function, commonly used for measuring dissimilarity between sets.
KullbackLeiblerDivergence<T> Implements the Kullback-Leibler Divergence, a measure of how one probability distribution differs from another.
LogCoshLoss<T> Implements the Log-Cosh loss function, a smooth approximation of Mean Absolute Error.
MarginLoss<T> Implements the Margin loss function, specifically designed for Capsule Networks.
MaskedRowLoss<T> Restricts another loss to a subset of the rows of a [rows, features] prediction, so the excluded rows contribute neither loss nor gradient.
MeanAbsoluteErrorLoss<T> Implements the Mean Absolute Error (MAE) loss function.
MeanBiasErrorLoss<T> Implements the Mean Bias Error (MBE) loss function.
MeanSquaredErrorLoss<T> Implements the Mean Squared Error (MSE) loss function.
ModifiedHuberLoss<T> Implements the Modified Huber Loss function, a smoother version of the hinge loss.
MultiResolutionStftLoss<T> Multi-resolution STFT loss: spectral convergence plus log-magnitude distance, summed over several STFT resolutions.
NegativeSiSnrLoss<T> Negative scale-invariant signal-to-noise ratio, with utterance-level permutation-invariant training (Luo & Mesgarani 2019, Sec.
NoiseContrastiveEstimationLoss<T> Implements the Noise Contrastive Estimation (NCE) loss function for efficient training with large output spaces.
OrdinalRegressionLoss<T> Implements the Ordinal Regression Loss function for predicting ordered categories.
PSNRLoss<T> The negative-PSNR objective BasicSR trains restoration networks with: the weighted mean over samples of 10/ln 10 · log(MSE + 1e-8).
PairwiseRankingLoss<T> Implements the pairwise RankNet learning-to-rank loss with an optional tail-weighting knob.
ParaformerObjective<T> Paraformer’s training objective: gamma * L_CE + L_MAE (Gao et al., arXiv 2206.08317, Eq 6).
PerceptualLoss<T> Implements the Perceptual Loss function for comparing high-level features of images.
PoissonLoss<T> Implements the Poisson loss function for count data modeling.
QuantileLoss<T> Implements the Quantile loss function for quantile regression.
QuantumLoss<T> Represents a quantum-specific loss function for quantum neural networks.
RealESRGANLoss<T> Combined loss function for Real-ESRGAN super-resolution training.
RootMeanSquaredErrorLoss<T> Implements the Root Mean Squared Error (RMSE) loss function.
RotationPredictionLoss<T> Self-supervised loss function based on rotation prediction for images.
ScaleInvariantDepthLoss<T> Scale-invariant depth loss function for depth estimation training.
SparseCategoricalCrossEntropyLoss<T> Implements the Sparse Categorical Cross Entropy loss function for multi-class classification with integer labels.
SquaredHingeLoss<T> Implements the Squared Hinge Loss function for binary classification problems.
TripletLoss<T> Implements the Triplet Loss function for learning similarity embeddings.
WassersteinLoss<T> Implements the Wasserstein loss function used in Wasserstein Generative Adversarial Networks (WGAN).
WeightedCrossEntropyLoss<T> Implements the Weighted Cross Entropy loss function for classification problems with uneven class importance.

Base Classes (1)

Type Summary
LossFunctionBase<T> Base class for loss function implementations.