kaira.losses.image.VGGLoss

Inheritance diagram for VGGLoss
- class kaira.losses.image.VGGLoss(layer_weights=None)[source]
Bases:
BaseLossVGG Perceptual Loss Module.
This module calculates the perceptual loss using features extracted by the VGG network. VGG loss measures similarity in feature space rather than pixel space, capturing perceptual differences better [Johnson et al., 2016] [Dosovitskiy and Brox, 2016].
Methods
Initialize the VGGLoss module.
Forward pass through the VGGLoss module.
- __init__(layer_weights=None)[source]
Initialize the VGGLoss module.
- Parameters:
layer_weights (dict, optional) – Weights for different VGG layers. Default is {‘conv1_2’: 0.1, ‘conv2_2’: 0.2, ‘conv3_3’: 0.4, ‘conv4_3’: 0.3}
- forward(x: Tensor, target: Tensor) Tensor[source]
Forward pass through the VGGLoss module.
- Parameters:
x (torch.Tensor) – The input tensor.
target (torch.Tensor) – The target tensor.
- Returns:
The VGG perceptual loss between the input and the target.
- Return type: