kaira.models.fec.decoders.BeliefPropagationPolarDecoder

Inheritance diagram for BeliefPropagationPolarDecoder
- class kaira.models.fec.decoders.BeliefPropagationPolarDecoder(encoder: PolarCodeEncoder, *args: Any, **kwargs: Any)[source]
Bases:
BaseBlockDecoder[PolarCodeEncoder]Decoder for Polar code using Belief Propagation (BP) method.
This class implements the Belief Propagation algorithm for decoding Polar codes. It processes the received codeword and estimates the transmitted message bits. The decoder supports two regimes: ‘sum_product’ and ‘min_sum’, and provides options for early stopping and cyclic permutations.
- encoder
The Polar code encoder used for encoding messages.
- Type:
- info_indices
Indices of information bits in the Polar code.
- Type:
- frozen_ind
Boolean array indicating frozen bits.
- Type:
- device
Device on which the decoder operates (e.g., CPU or GPU).
- Type:
- dtype
Data type used for computations.
- Type:
- mask_dict
Mask dictionary for the Polar code structure.
- Type:
- permutations
Array of cyclic permutations.
- Type:
Methods
Initializes the BeliefPropagationPolarDecoder.
Check node operation for the Belief Propagation Polar Decoder.
Performs iterative decoding using the Belief Propagation algorithm.
Decodes the received codeword using the Belief Propagation algorithm.
Generates cyclic permutations for decoding.
Prints the type of decoder being used, along with its configuration.
Updates the left messages in the decoding graph.
Updates the right messages in the decoding graph.
Attributes
Get the code dimension (k).
Get the code length (n).
Get the code rate (k/n).
Get the code redundancy (r = n - k).
- __init__(encoder: PolarCodeEncoder, *args: Any, **kwargs: Any)[source]
Initializes the BeliefPropagationPolarDecoder.
Args: encoder (PolarCodeEncoder): The Polar code encoder used for encoding messages. bp_iters (int): Number of iterations for decoding. early_stop (bool): Whether to use early stopping during decoding. regime (str): Decoding regime (‘sum_product’ or ‘min_sum’). clip (float): Clipping value for numerical stability. perm (str or None): Type of permutation of the factor graph used (‘cycle’ or None).
- get_cyclic_permutations(perm=None)[source]
Generates cyclic permutations for decoding.
- Parameters:
perm (str or None) – Type of permutation (‘cycle’ or None).
- checknode(y1, y2)[source]
Check node operation for the Belief Propagation Polar Decoder.
- Parameters:
y1 (torch.Tensor) – Input message 1.
y2 (torch.Tensor) – Input message 2.
- Returns:
Output message after applying the check node operation.
- Return type:
- update_right(R, L, perm)[source]
Updates the right messages in the decoding graph.
- Parameters:
R (torch.Tensor) – Right message tensor.
L (torch.Tensor) – Left message tensor.
perm (torch.Tensor) – Permutation array.
- Returns:
Updated right message tensor.
- Return type:
- update_left(R, L, perm)[source]
Updates the left messages in the decoding graph.
- Parameters:
R (torch.Tensor) – Right message tensor.
L (torch.Tensor) – Left message tensor.
perm (torch.Tensor) – Permutation array.
- Returns:
Updated left message tensor.
- Return type:
- decode_iterative(llr: Tensor)[source]
Performs iterative decoding using the Belief Propagation algorithm.
- Parameters:
llr (torch.Tensor) – Log-likelihood ratio tensor of shape (batch_size, N).
- Returns:
Decoded message bits and codeword bits.
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- property code_dimension: int
Get the code dimension (k).
The code dimension is the number of information bits in each codeword, representing the actual data being transmitted.
- Returns:
The dimension of the code (number of information bits)
- property code_length: int
Get the code length (n).
The code length is the total number of bits in each codeword, including both information bits and redundancy bits.
- Returns:
The length of the code (number of bits in a codeword)
- property code_rate: float
Get the code rate (k/n).
The code rate is the ratio of information bits to the total bits, indicating the coding efficiency. Higher rates mean more efficient use of the channel but typically lower error correction capability.
- Returns:
The rate of the code (ratio of information bits to total bits)
- forward(received: Tensor, *args: Any, **kwargs: Any) Tensor[source]
Decodes the received codeword using the Belief Propagation algorithm.
- Parameters:
received (torch.Tensor) – Received codeword tensor of shape (batch_size, code_length).
- Returns:
Estimated message bits of shape (batch_size, code_dimension).
- Return type: