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

Method forward

func_2d/utils.py:245–252  ·  view source on GitHub ↗
(self, input, target)

Source from the content-addressed store, hash-verified

243 """Dice coeff for individual examples"""
244
245 def forward(self, input, target):
246 self.save_for_backward(input, target)
247 eps = 0.0001
248 self.inter = torch.dot(input.view(-1), target.view(-1))
249 self.union = torch.sum(input) + torch.sum(target) + eps
250
251 t = (2 * self.inter.float() + eps) / self.union.float()
252 return t
253
254 # This function has only a single output, so it gets only one gradient
255 def backward(self, grad_output):

Callers 1

dice_coeffFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected