Losses¶
RMS signal energy loss function.
This module is part of the libdamp package.
- class libdamp.losses.rms.RMSLoss(N: int = 512, H: int = 256, window_type: str = 'hann')[source]¶
Bases:
ModuleRMS signal energy loss function.
Compares the energy of two input signals within a moving window.
- forward(y: Tensor, y_hat: Tensor) Tensor[source]¶
Compare energy of two input signals using moving window RMS.
- Parameters:
y (torch.Tensor) – Reference audio signal, shape (batch, samples).
y_hat (torch.Tensor) – Estimated audio signal, shape (batch, samples).
- Returns:
Loss value per batch item, shape (batch,).
- Return type:
Multi-Scale Spectral Loss.
This module is part of the libdamp package.
- class libdamp.losses.mss.MSSLoss(w_mag: float | Sequence[float] = 1.0, w_log: float | Sequence[float] = 0.0, w_mlog: float | Sequence[float] = 0.0, mgamma: float = 1.0, p: int = 1, fft_sizes: tuple[int, ...] = (2048, 1024, 512, 256, 128, 64), win: str = 'hann')[source]¶
Bases:
ModuleMulti-scale spectral loss.
- update(w_mag=None, w_log=None, w_mlog=None, mgamma=None, p=None, fft_sizes=None, win=None)[source]¶
Update loss parameters. Useful for dynamic loss balancing / scheduling.
- forward(y: Tensor, y_hat: Tensor) Tensor[source]¶
Forward pass with two input signals to compare.
- Parameters:
y (torch.Tensor) – Reference audio signal, shape (batch, samples).
y_hat (torch.Tensor) – Estimated audio signal, shape (batch, samples).
- Returns:
Loss value per batch item, shape (batch,).
- Return type: