torchcell.losses.mle_wasserstein.BufferedWeightedWassersteinLoss
- class BufferedWeightedWassersteinLoss(buffer_size: int = 256, blur: float = 0.05, p: float = 2, scaling: float = 0.9, weights: Tensor | None = None, min_samples: int = 64)[source]
Bases:
ModuleEnhanced Wasserstein loss with circular buffer for small batch training.
- update_buffer(predictions: Tensor, targets: Tensor) None[source]
Update circular buffer with new samples.
- forward(predictions: Tensor, targets: Tensor, all_predictions: Tensor | None = None, all_targets: Tensor | None = None, buffer_weight: float = 1.0) tuple[Tensor, Tensor][source]
Compute Wasserstein loss with buffer support.
- Parameters:
predictions – Local batch predictions
targets – Local batch targets
all_predictions – Gathered predictions from all GPUs (optional)
all_targets – Gathered targets from all GPUs (optional)
buffer_weight – Weight for buffer contribution (0-1)