kaira.models.binary.soft_bit_thresholding.AdaptiveThresholder

Inheritance diagram for AdaptiveThresholder
- class kaira.models.binary.soft_bit_thresholding.AdaptiveThresholder(method: str = 'mean', scale_factor: float = 1.0, input_type: InputType = InputType.PROBABILITY, *args: Any, **kwargs: Any)[source]
Bases:
SoftBitThresholderAdaptive thresholder for soft bit values.
Adjusts the threshold based on the statistics of the input signal. This can be useful in varying channel conditions where a fixed threshold may not be optimal.
Supports different adaptive threshold methods: - ‘mean’: Uses the mean of the input as threshold - ‘median’: Uses the median of the input as threshold - ‘otsu’: Uses Otsu’s method for optimal bimodal threshold
Methods
Initialize the adaptive thresholder.
Apply adaptive thresholding to convert soft bit values to hard decisions.
Create model instance from configuration.
Create model from Hydra DictConfig.
Create model from Hugging Face PretrainedConfig.
Move the model to the specified device.
- __init__(method: str = 'mean', scale_factor: float = 1.0, input_type: InputType = InputType.PROBABILITY, *args: Any, **kwargs: Any)[source]
Initialize the adaptive thresholder.
- Parameters:
method – Method to use for adaptive thresholding (‘mean’, ‘median’, ‘otsu’).
scale_factor – Factor to scale the computed threshold.
input_type – Type of soft input (‘prob’ or ‘llr’).
*args – Variable positional arguments passed to the base class.
**kwargs – Variable keyword arguments passed to the base class.
- forward(x: Tensor, *args: Any, **kwargs: Any) Tensor[source]
Apply adaptive thresholding to convert soft bit values to hard decisions.
- Parameters:
x – Input tensor of soft bit values.
*args – Additional positional arguments (unused).
**kwargs – Additional keyword arguments (unused).
- Returns:
Tensor of hard bit decisions (0.0 or 1.0).
- classmethod from_config(config, **kwargs)
Create model instance from configuration.
- Parameters:
config – Configuration object (PretrainedConfig, DictConfig, or dict)
**kwargs – Additional parameters to override config
- Returns:
Model instance
- classmethod from_hydra_config(config: DictConfig, **kwargs)
Create model from Hydra DictConfig.
- Parameters:
config – Hydra configuration
**kwargs – Additional parameters
- Returns:
Model instance
- classmethod from_pretrained_config(config: PretrainedConfig, **kwargs)
Create model from Hugging Face PretrainedConfig.
- Parameters:
config – PretrainedConfig instance
**kwargs – Additional parameters
- Returns:
Model instance
- to(device: str | device, *args, **kwargs) SoftBitThresholder
Move the model to the specified device.
- Parameters:
device – The device to move the model to.
*args – Additional positional arguments for nn.Module.to().
**kwargs – Additional keyword arguments for nn.Module.to().
- Returns:
Self for method chaining.