kaira.metrics.signal.SignalToNoiseRatio

Inheritance diagram of SignalToNoiseRatio

Inheritance diagram for SignalToNoiseRatio

class kaira.metrics.signal.SignalToNoiseRatio(name: str | None = None, mode: str = 'db', *args: Any, **kwargs: Any)[source]

Bases: BaseMetric

Signal-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].

mode

Output mode - “db” for decibels or “linear” for linear ratio.

Type:

str

Methods

__init__

Initialize the SNR metric.

compute_with_stats

Compute SNR with mean and standard deviation across batches.

forward

Compute the Signal-to-Noise Ratio (SNR).

reset

Reset accumulated statistics.

Examples using kaira.metrics.signal.SignalToNoiseRatio

Simulating AWGN Channels with Kaira

Simulating AWGN Channels with Kaira

Composite Metrics

Composite Metrics

Metrics Registry

Metrics Registry

Signal and Error Rate Metrics

Signal and Error Rate Metrics
__init__(name: str | None = None, mode: str = 'db', *args: Any, **kwargs: Any)[source]

Initialize the SNR metric.

Parameters:
  • name (Optional[str]) – Optional name for the metric

  • mode (str) – Output mode - “db” for decibels or “linear” for linear ratio

  • *args – Variable length argument list passed to the base class.

  • **kwargs – Arbitrary keyword arguments passed to the base class.

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.