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

Method forward

func_3d/utils.py:231–238  ·  view source on GitHub ↗
(self, input, target)

Source from the content-addressed store, hash-verified

229 """Dice coeff for individual examples"""
230
231 def forward(self, input, target):
232 self.save_for_backward(input, target)
233 eps = 0.0001
234 self.inter = torch.dot(input.view(-1), target.view(-1))
235 self.union = torch.sum(input) + torch.sum(target) + eps
236
237 t = (2 * self.inter.float() + eps) / self.union.float()
238 return t
239
240 # This function has only a single output, so it gets only one gradient
241 def backward(self, grad_output):

Callers 1

dice_coeffFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected