NegativeSiSnrLoss<T>

Models & Types · AiDotNet.LossFunctions

Negative scale-invariant signal-to-noise ratio, with utterance-level permutation-invariant training (Luo & Mesgarani 2019, Sec. III-D; Le Roux et al. 2019).

Inheritance: LossFunctionBase<T> → NegativeSiSnrLoss<T>

For Beginners

SI-SNR asks “how much of the estimate is the right signal, and how much is leftover noise”, ignoring overall volume. Higher is better, so training minimizes its negative.

How It Works

For an estimate ŝ and a reference s, both made zero-mean over time: s_target = (⟨ŝ, s⟩ / ‖s‖²) s, e_noise = ŝ − s_target, and SI-SNR = 10 log10(‖s_target‖² / ‖e_noise‖²). Rescaling the estimate does not change it, so a separator is not rewarded for matching loudness. The loss is its negative, so it can be below zero.

A separator’s output channels have no fixed order, so for [batch, sources, samples] each example takes the assignment of estimates to references with the highest mean SI-SNR, found exactly by the Hungarian method on the pairwise SI-SNR matrix; the gradient flows only through that assignment, which is permutation-invariant training. Rank 1 or 2 inputs are a single source.

Example

using AiDotNet.LossFunctions;
using AiDotNet.Tensors.LinearAlgebra;

var loss = new NegativeSiSnrLoss<float>();
var predicted = new Vector<float>(new[] { 0.9f, 0.2f, 0.7f });
var actual = new Vector<float>(new[] { 1.0f, 0.0f, 1.0f });

float value = loss.CalculateLoss(predicted, actual);
Console.WriteLine($"NegativeSiSnrLoss = {value:F4}");

Constructors

Constructor Summary
NegativeSiSnrLoss()

Methods

Method Summary
T CalculateLoss(Vector<T> predicted, Vector<T> actual) Negative SI-SNR of ONE estimated signal against ONE reference.
Tensor<T> ComputeTapeLoss(Tensor<T> predicted, Tensor<T> target)