kaira.losses.audio.FeatureMatchingLoss

Inheritance diagram of FeatureMatchingLoss

Inheritance diagram for FeatureMatchingLoss

class kaira.losses.audio.FeatureMatchingLoss(model, layers, weights=None)[source]

Bases: BaseLoss

Feature Matching Loss Module.

This module calculates the loss between features extracted from a pretrained model.

Methods

__init__

Initialize the FeatureMatchingLoss module.

forward

Forward pass through the FeatureMatchingLoss module.

__init__(model, layers, weights=None)[source]

Initialize the FeatureMatchingLoss module.

Parameters:
  • model (BaseLoss) – Pretrained model for feature extraction.

  • layers (list) – List of layer indices to extract features from.

  • weights (list, optional) – Weights for each layer. Default is None (equal weights).

forward(x: Tensor, target: Tensor) Tensor[source]

Forward pass through the FeatureMatchingLoss module.

Parameters:
Returns:

The feature matching loss.

Return type:

torch.Tensor