torchcvnn.transforms.LogAmplitude¶
- class torchcvnn.transforms.LogAmplitude(min_value: float = 0.02, max_value: float = 40, keep_phase: bool = True)[source]¶
This transform applies a logarithmic scaling to the amplitude/magnitude of complex values while optionally preserving the phase information. The amplitude is first clipped to [min_value, max_value] range, then log10-transformed and normalized to [0,1] range.
The transformation follows these steps: 1. Extract amplitude and phase from complex input 2. Clip amplitude between min_value and max_value 3. Apply log10 transform and normalize to [0,1] 4. Optionally recombine with original phase
- Parameters:
min_value (int | float, optional) – Minimum amplitude value for clipping. Values below this will be clipped up. Defaults to 0.02.
max_value (int | float, optional) – Maximum amplitude value for clipping. Values above this will be clipped down. Defaults to 40.
keep_phase (bool, optional) – Whether to preserve phase information. If True, returns complex output with transformed amplitude and original phase. If False, returns just the transformed amplitude. Defaults to True.
- Returns:
- Transformed tensor with same shape as input.
If keep_phase=True: Complex tensor with log-scaled amplitude and original phase If keep_phase=False: Real tensor with just the log-scaled amplitude
- Return type:
np.ndarray | torch.Tensor
Example
>>> transform = LogAmplitude(min_value=0.01, max_value=100) >>> output = transform(input_tensor) # Transforms amplitudes to log scale [0,1]
Note
The transform works with both NumPy arrays and PyTorch tensors through separate internal implementations (__call_numpy__ and __call_torch__).
Methods
__init__
([min_value, max_value, keep_phase])