MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / CombinedLoss

Class CombinedLoss

func_3d/function.py:20–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18args = cfg.parse_args()
19
20class CombinedLoss(nn.Module):
21 def __init__(self, dice_weight=1, focal_weight=1):
22 super(CombinedLoss, self).__init__()
23 self.dice_weight = dice_weight
24 self.focal_weight = focal_weight
25 self.dice_loss = DiceLoss(to_onehot_y=True, sigmoid=True)
26 self.focal_loss = FocalLoss(to_onehot_y=True, gamma=2.0)
27
28 def forward(self, inputs, targets):
29 dice = self.dice_loss(inputs, targets)
30 focal = self.focal_loss(inputs, targets)
31 return self.dice_weight * dice + self.focal_weight * focal
32
33
34GPUdevice = torch.device('cuda', args.gpu_device)

Callers 1

function.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected