Module: sarpyx.utils.sar_loss

File: sarpyx/utils/sar_loss.py

Loss Functions for Complex-Valued SAR Image Super-Resolution. This module provides specialized loss functions for Synthetic Aperture Radar (SAR) image super-resolution tasks, handling both amplitude and phase components of complex-valued SAR data.

Exported Symbols (__all__)

No explicit __all__ list. Public symbols inferred from implementation.

Public Functions (15)

amplitude_l1_loss function

Compute L1 loss between magnitudes of predicted and target complex SAR images.

File location: sarpyx/utils/sar_loss.py:18

Signature

amplitude_l1_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor of shape (..., H, W) or (..., H, W, 2)
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the L1 amplitude loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import amplitude_l1_loss

result = amplitude_l1_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

amplitude_l2_loss function

Compute L2 loss (MSE) between magnitudes of predicted and target SAR images.

File location: sarpyx/utils/sar_loss.py:48

Signature

amplitude_l2_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor of shape (..., H, W) or (..., H, W, 2)
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the L2 amplitude loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import amplitude_l2_loss

result = amplitude_l2_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

amplitude_ssim_loss function

Compute SSIM loss between magnitudes of predicted and target SAR images.

File location: sarpyx/utils/sar_loss.py:79

Signature

amplitude_ssim_loss(pred: torch.Tensor, target: torch.Tensor, window_size: int=11) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor of shape (B, C, H, W) or (H, W)
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred
window_sizeintno11Size of Gaussian window for SSIM computation

Return Type

torch.Tensor

Scalar tensor representing the SSIM loss (1 - SSIM)

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import amplitude_ssim_loss

result = amplitude_ssim_loss(pred=<pred>, target=<target>)

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

amplitude_log_cosh_loss function

Compute log-cosh loss between magnitudes of predicted and target SAR images.

File location: sarpyx/utils/sar_loss.py:151

Signature

amplitude_log_cosh_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor of shape (..., H, W) or (..., H, W, 2)
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the log-cosh amplitude loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import amplitude_log_cosh_loss

result = amplitude_log_cosh_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

phase_l1_loss function

Compute L1 loss between phases of predicted and target complex SAR images.

File location: sarpyx/utils/sar_loss.py:187

Signature

phase_l1_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the phase L1 loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import phase_l1_loss

result = phase_l1_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

phase_l2_loss function

Compute L2 loss between phases of predicted and target complex SAR images.

File location: sarpyx/utils/sar_loss.py:223

Signature

phase_l2_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the phase L2 loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import phase_l2_loss

result = phase_l2_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

phase_wrapping_error_loss function

Compute phase wrapping error loss between predicted and target SAR images.

File location: sarpyx/utils/sar_loss.py:257

Signature

phase_wrapping_error_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the phase wrapping error loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import phase_wrapping_error_loss

result = phase_wrapping_error_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

phase_correlation_loss function

Compute phase correlation loss between predicted and target complex SAR images.

File location: sarpyx/utils/sar_loss.py:283

Signature

phase_correlation_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the phase correlation loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import phase_correlation_loss

result = phase_correlation_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

complex_l2_loss function

Compute MSE between predicted and target complex SAR images.

File location: sarpyx/utils/sar_loss.py:325

Signature

complex_l2_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the complex L2 loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import complex_l2_loss

result = complex_l2_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

complex_correlation_loss function

Compute loss based on complex correlation between predicted and target SAR images.

File location: sarpyx/utils/sar_loss.py:366

Signature

complex_correlation_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the complex correlation loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import complex_correlation_loss

result = complex_correlation_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

coherence_loss function

Compute interferometric coherence loss between predicted and target SAR images.

File location: sarpyx/utils/sar_loss.py:404

Signature

coherence_loss(pred: torch.Tensor, target: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor of same shape as pred

Return Type

torch.Tensor

Scalar tensor representing the coherence loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import coherence_loss

result = coherence_loss(pred=<pred>, target=<target>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

gan_generator_loss function

Compute adversarial loss for generator in GAN training.

File location: sarpyx/utils/sar_loss.py:444

Signature

gan_generator_loss(disc_pred: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
disc_predtorch.Tensoryes-Discriminator's output probabilities for generated images

Return Type

torch.Tensor

Scalar tensor representing the generator's adversarial loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import gan_generator_loss

result = gan_generator_loss(disc_pred=<disc_pred>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

gan_discriminator_loss function

Compute discriminator loss in GAN for SAR super-resolution.

File location: sarpyx/utils/sar_loss.py:470

Signature

gan_discriminator_loss(disc_real: torch.Tensor, disc_fake: torch.Tensor) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
disc_realtorch.Tensoryes-Discriminator predictions on real images
disc_faketorch.Tensoryes-Discriminator predictions on generated images

Return Type

torch.Tensor

Scalar tensor representing the discriminator loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import gan_discriminator_loss

result = gan_discriminator_loss(disc_real=<disc_real>, disc_fake=<disc_fake>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

perceptual_loss function

Compute perceptual feature loss using pretrained feature extractor.

File location: sarpyx/utils/sar_loss.py:502

Signature

perceptual_loss(pred: torch.Tensor, target: torch.Tensor, feature_extractor: nn.Module) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted SAR image tensor
targettorch.Tensoryes-Target SAR image tensor of same shape as pred
feature_extractornn.Moduleyes-Pretrained CNN for feature extraction (e.g., VGG)

Return Type

torch.Tensor

Scalar tensor representing the perceptual loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import perceptual_loss

result = perceptual_loss(pred=<pred>, target=<target>, feature_extractor=<feature_extractor>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

combined_sar_loss function

Compute combined SAR loss with multiple components.

File location: sarpyx/utils/sar_loss.py:547

Signature

combined_sar_loss(pred: torch.Tensor, target: torch.Tensor, amplitude_weight: float=1.0, phase_weight: float=0.5, complex_weight: float=0.3, ssim_weight: float=0.2) -> torch.Tensor

Parameters

ParameterTypeRequiredDefaultDescription
predtorch.Tensoryes-Predicted complex SAR image tensor
targettorch.Tensoryes-Target complex SAR image tensor
amplitude_weightfloatno1.0Weight for amplitude L1 loss
phase_weightfloatno0.5Weight for phase L1 loss
complex_weightfloatno0.3Weight for complex L2 loss
ssim_weightfloatno0.2Weight for SSIM loss

Return Type

torch.Tensor

Scalar tensor representing the combined loss

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.utils.sar_loss import combined_sar_loss

result = combined_sar_loss(pred=<pred>, target=<target>)

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

Public Classes (0)

No public classes detected.