ncalab.losses

Classes

DiceScore

Pytorch Module that computes the Dice overlap score between two images.

DiceBCELoss

Combination of Dice and BCE Loss between two images.

Module Contents

class ncalab.losses.DiceScore

Bases: torch.nn.Module

Pytorch Module that computes the Dice overlap score between two images.

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: torch.Tensor, y: torch.Tensor, smooth: float = 1.0) torch.Tensor
Parameters:
  • x (torch.Tensor) – Reference Input

  • y (torch.Tensor) – Other Input

  • smooth (float) – Smooting factor, defaults to 1.0

Returns:

Dice score

Return type:

torch.Tensor

class ncalab.losses.DiceBCELoss

Bases: torch.nn.Module

Combination of Dice and BCE Loss between two images.

Initialize internal Module state, shared by both nn.Module and ScriptModule.

dicescore
forward(x: torch.Tensor, y: torch.Tensor, smooth: float = 1.0) torch.Tensor
Parameters:
  • x (torch.Tensor) – Reference Input

  • y (torch.Tensor) – Other Input

  • smooth (float) – Smooting factor, defaults to 1.0

Returns:

Dice score

Return type:

torch.Tensor