kaira.metrics.signal.BlockErrorRate

Inheritance diagram of BlockErrorRate

Inheritance diagram for BlockErrorRate

class kaira.metrics.signal.BlockErrorRate(block_size: int | None = None, threshold: float = 0.0, reduction: str = 'mean', name: str | None = None, *args: Any, **kwargs: Any)[source]

Bases: BaseMetric

Block Error Rate (BLER) metric.

BLER measures the number of blocks containing at least one error divided by the total number of blocks transmitted. Lower values indicate better performance. It’s commonly used in systems employing block codes [Lin and Costello, 2004].

This metric can also be used for Frame Error Rate (FER) or Symbol Error Rate (SER) by setting the block_size appropriately or leaving it as None to treat each row as a block/frame/symbol.

block_size

Size of each block. If None, each row is a block.

Type:

Optional[int]

threshold

Threshold for considering values as different.

Type:

float

reduction

Reduction method (‘mean’, ‘sum’, ‘none’).

Type:

str

total_blocks

Accumulated total number of blocks processed.

Type:

Tensor

error_blocks

Accumulated number of blocks with errors.

Type:

Tensor

Methods

__init__

Initialize the BlockErrorRate module.

compute

Compute accumulated block error rate.

compute_with_stats

Compute metric with mean and standard deviation.

forward

Compute the Block Error Rate for the current batch.

reset

Reset accumulated statistics.

update

Update accumulated statistics with results from a new batch.

Attributes

higher_is_better

is_differentiable

is_differentiable = False
higher_is_better = False
__init__(block_size: int | None = None, threshold: float = 0.0, reduction: str = 'mean', name: str | None = None, *args: Any, **kwargs: Any) None[source]

Initialize the BlockErrorRate module.

Parameters:
  • block_size (Optional[int]) – Size of each block in the input. If None, each row of the input is treated as a separate block.

  • threshold (float) – Threshold for considering values as different. Useful for floating-point comparisons.

  • reduction (str) – Reduction method: ‘mean’, ‘sum’, or ‘none’.

  • name (Optional[str]) – Name for the metric.

  • *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 Block Error Rate for the current batch.

Parameters:
  • x (Tensor) – The predicted tensor.

  • y (Tensor) – The target tensor.

  • *args – Variable length argument list (unused).

  • **kwargs – Arbitrary keyword arguments (unused).

Returns:

Block error rate for the batch, potentially reduced.

Return type:

Tensor

update(x: Tensor, y: Tensor, *args: Any, **kwargs: Any) None[source]

Update accumulated statistics with results from a new batch.

Parameters:
  • x (Tensor) – The predicted tensor for the current batch.

  • y (Tensor) – The target tensor for the current batch.

  • *args – Variable length argument list (unused).

  • **kwargs – Arbitrary keyword arguments (unused).

compute() Tensor[source]

Compute accumulated block error rate.

Returns:

Block error rate value

Return type:

Tensor

reset() None[source]

Reset accumulated statistics.

compute_with_stats(x: Tensor, y: Tensor, *args: Any, **kwargs: Any) Tuple[Tensor, Tensor]

Compute metric with mean and standard deviation.

Parameters:
  • x (torch.Tensor) – The first input tensor (typically predictions)

  • y (torch.Tensor) – The second input tensor (typically targets)

  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

Returns:

Mean and standard deviation of the metric

Return type:

Tuple[torch.Tensor, torch.Tensor]