kaira.constraints.PeakAmplitudeConstraint

Inheritance diagram for PeakAmplitudeConstraint
- class kaira.constraints.PeakAmplitudeConstraint(max_amplitude: float, *args, **kwargs)[source]
Bases:
BaseConstraintEnforces maximum signal amplitude by clipping values that exceed threshold.
Limits the maximum amplitude of the signal to prevent clipping in digital-to-analog converters (DACs) and power amplifiers. This constraint applies a hard clipping operation to ensure signal values remain within the specified bounds. Peak amplitude constraints are critical for practical communication systems as discussed in [Armstrong, 2002] and [Jiang and Wu, 2008].
Methods
Initialize the peak amplitude constraint.
Apply peak amplitude constraint.
Helper method to get all dimensions except batch for calculating norms/means.
- __init__(max_amplitude: float, *args, **kwargs) None[source]
Initialize the peak amplitude constraint.
- Parameters:
max_amplitude (float) – Maximum allowed amplitude. Signal values exceeding this threshold (positive or negative) will be clipped.
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- forward(x: Tensor, *args, **kwargs) Tensor[source]
Apply peak amplitude constraint.
Clips the input signal to ensure all values fall within the range [-max_amplitude, max_amplitude].
- Parameters:
x (torch.Tensor) – Input tensor of any shape
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- Returns:
Amplitude-constrained signal with the same shape as input
- Return type:
- static get_dimensions(x: Tensor, exclude_batch: bool = True) Tuple[int, ...]
Helper method to get all dimensions except batch for calculating norms/means.
Utility function to generate dimension indices for reduction operations like mean or norm. Typically used to calculate signal properties across all dimensions except the batch dimension.
- Parameters:
x (torch.Tensor) – Input tensor
exclude_batch (bool, optional) – Whether to exclude the batch dimension (first dimension). Defaults to True.
- Returns:
Dimensions to use for reduction operations (e.g., mean, norm)
- Return type:
Tuple[int, …]
Example
>>> x = torch.randn(32, 4, 128) # [batch, antennas, time] >>> dims = BaseConstraint.get_dimensions(x) >>> # dims will be (1, 2) for summing across antennas and time