kaira.models.binary.soft_bit_thresholding.HysteresisThresholder

Inheritance diagram of HysteresisThresholder

Inheritance diagram for HysteresisThresholder

class kaira.models.binary.soft_bit_thresholding.HysteresisThresholder(high_threshold: float = 0.6, low_threshold: float = 0.4, input_type: InputType = InputType.PROBABILITY, initial_state: Tensor | None = None, *args: Any, **kwargs: Any)[source]

Bases: SoftBitThresholder

Thresholder with hysteresis for robust decision making in noisy environments.

Uses two thresholds to create a hysteresis effect, providing more stable decisions for values near the decision boundary. Values must cross a higher threshold to transition from 0→1, and a lower threshold to transition from 1→0.

This approach reduces oscillations in the output when the input signal is noisy or fluctuating around the threshold.

Example

With high_threshold=0.6, low_threshold=0.4: - Values > 0.6 are classified as 1 - Values < 0.4 are classified as 0 - Values between 0.4 and 0.6 maintain their previous state

Methods

__init__

Initialize the hysteresis thresholder.

forward

Apply hysteresis thresholding to convert soft bit values to hard decisions.

reset_state

Reset the internal state of the hysteresis thresholder.

to

Move the model to the specified device.

__init__(high_threshold: float = 0.6, low_threshold: float = 0.4, input_type: InputType = InputType.PROBABILITY, initial_state: Tensor | None = None, *args: Any, **kwargs: Any)[source]

Initialize the hysteresis thresholder.

Parameters:
  • high_threshold – Threshold to cross for transitioning from 0→1.

  • low_threshold – Threshold to cross for transitioning from 1→0.

  • input_type – Type of soft input (‘prob’ or ‘llr’).

  • initial_state – Optional tensor with initial states. If None, all values start at state 0.

  • *args – Variable positional arguments passed to the base class.

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

reset_state(initial_state: Tensor | None = None)[source]

Reset the internal state of the hysteresis thresholder.

Parameters:

initial_state – Optional tensor with initial states. If None, state is set to None and will be initialized on the first forward pass.

forward(x: Tensor, reset_state: bool = False, *args: Any, **kwargs: Any) Tensor[source]

Apply hysteresis thresholding to convert soft bit values to hard decisions.

Parameters:
  • x – Input tensor of soft bit values.

  • reset_state – If True, internal state is reset before processing.

  • *args – Additional positional arguments (unused).

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

Returns:

Tensor of hard bit decisions (0.0 or 1.0).

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.