Losses Utils¶
- class master_thesis.utils.LossesUtils¶
Bases:
objectUtilities class containing loss-related methods.
- static masked_l1(y_hat, y, mask, batch_mask=None, reduction='mean', weight=1)¶
- static perceptual(y_hat, y, model_vgg, weight=1)¶
Computes the perceptual loss of the image
y_hatwith respect to the ground truthy.- Parameters
y_hat – Tensor of size
(B,C,H,W)containing the estimated image.y – Tensor of size
(B,C,H,W)containing the ground-truth image.weight – Scaling factor applied to the loss.
- Returns
Perceptual loss between
y_hatandy.
- static grad(y_hat, y, reduction, weight=1)¶
Computes the gradient loss of the image
y_hatwith respect to the ground truthy.- Parameters
y_hat – Tensor of size
(B,C,H,W)containing the estimated image.y – Tensor of size
(B,C,H,W)containing the ground-truth image.reduction – Reduction mode applied to the loss.
weight – Scaling factor applied to the loss.
- Returns
Gradient loss between
y_hatandy.