kaira.metrics.signal.SignalToNoiseRatio

Inheritance diagram for SignalToNoiseRatio
- class kaira.metrics.signal.SignalToNoiseRatio(name: str | None = None, mode: str = 'db', *args: Any, **kwargs: Any)[source]
Bases:
BaseMetricSignal-to-Noise Ratio (SNR) metric.
SNR measures the ratio of signal power to noise power, often expressed in decibels (dB). Higher values indicate better signal quality. It’s a fundamental metric in signal processing and communications [Goldsmith, 2005] [Sklar, 2001].
Methods
Initialize the SNR metric.
Compute SNR with mean and standard deviation across batches.
Compute the Signal-to-Noise Ratio (SNR).
Reset accumulated statistics.
Examples using
kaira.metrics.signal.SignalToNoiseRatio- __init__(name: str | None = None, mode: str = 'db', *args: Any, **kwargs: Any)[source]
Initialize the SNR metric.
- forward(x: Tensor, y: Tensor, *args: Any, **kwargs: Any) Tensor[source]
Compute the Signal-to-Noise Ratio (SNR).
- Parameters:
x (Tensor) – The original (clean) signal tensor.
y (Tensor) – The noisy signal tensor.
*args – Variable length argument list (unused).
**kwargs – Arbitrary keyword arguments (unused).
- Returns:
The computed SNR value(s). If input is batched, returns SNR per batch element.
- Return type:
Tensor
- compute_with_stats(x: Tensor, y: Tensor, *args: Any, **kwargs: Any) Tuple[Tensor, Tensor][source]
Compute SNR with mean and standard deviation across batches.
- Parameters:
x (Tensor) – The original (clean) signal tensor (batched).
y (Tensor) – The noisy signal tensor (batched).
*args – Variable length argument list (unused).
**kwargs – Arbitrary keyword arguments (unused).
- Returns:
Mean and standard deviation of the SNR values across the batch.
- Return type:
Tuple[Tensor, Tensor]
- reset() None[source]
Reset accumulated statistics.
For SNR, there are no accumulated statistics to reset as it’s a direct computation.
- get_expected_args()
Return expected argument names for the metric.