mmagic.models.losses.gradient_loss
¶
Module Contents¶
Classes¶
Gradient loss. |
Attributes¶
- class mmagic.models.losses.gradient_loss.GradientLoss(loss_weight: float = 1.0, reduction: str = 'mean')[source]¶
Bases:
torch.nn.Module
Gradient loss.
- Parameters
loss_weight (float) – Loss weight for L1 loss. Default: 1.0.
reduction (str) – Specifies the reduction to apply to the output. Supported choices are ‘none’ | ‘mean’ | ‘sum’. Default: ‘mean’.
- forward(pred: torch.Tensor, target: torch.Tensor, weight: Optional[torch.Tensor] = None) torch.Tensor [source]¶
- Parameters
pred (Tensor) – of shape (N, C, H, W). Predicted tensor.
target (Tensor) – of shape (N, C, H, W). Ground truth tensor.
weight (Tensor, optional) – of shape (N, C, H, W). Element-wise weights. Default: None.