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

Method backward

func_2d/utils.py:255–266  ·  view source on GitHub ↗
(self, grad_output)

Source from the content-addressed store, hash-verified

253
254 # This function has only a single output, so it gets only one gradient
255 def backward(self, grad_output):
256
257 input, target = self.saved_variables
258 grad_input = grad_target = None
259
260 if self.needs_input_grad[0]:
261 grad_input = grad_output * 2 * (target * self.union - self.inter) \
262 / (self.union * self.union)
263 if self.needs_input_grad[1]:
264 grad_target = None
265
266 return grad_input, grad_target
267
268
269def dice_coeff(input, target):

Callers 1

train_samFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected