MCPcopy Create free account
hub / github.com/HiLab-git/ACELoss / elastica

Method elastica

aceloss.py:370–381  ·  view source on GitHub ↗
(self, input, a=1, b=1)

Source from the content-addressed store, hash-verified

368 return region
369
370 def elastica(self, input, a=1, b=1):
371 ci, cj, ck = self.first_derivative(input)
372 cii, cjj, ckk, cij, cik, cjk = self.second_derivative(
373 input, ci, cj, ck)
374 beta = 1e-8
375 length = torch.sqrt(beta + ci ** 2 + cj ** 2 + ck ** 2)
376 curvature = (1 + ci ** 2 + cj ** 2) * ckk + (1 + cj ** 2 + ck ** 2) * cii + (
377 1 + ci ** 2 + ck ** 2) * cjj - 2 * cik * cjk * cij
378 curvature = torch.abs(curvature) / \
379 ((1 + ci ** 2 + cj ** 2 + ck ** 2) ** 0.5 + beta)
380 elastica = torch.sum(a + b * (curvature ** 2) * torch.abs(length))
381 return elastica
382
383 def forward(self, y_pred, y_true):
384 loss = self.region(y_pred, y_true, u=self.miu) + \

Callers 1

forwardMethod · 0.95

Calls 2

first_derivativeMethod · 0.95
second_derivativeMethod · 0.95

Tested by

no test coverage detected