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

Function elastica

aceloss.py:152–161  ·  view source on GitHub ↗
(input, a=1, b=1)

Source from the content-addressed store, hash-verified

150 return region
151
152 def elastica(input, a=1, b=1):
153 ci, cj = first_derivative(input)
154 cii, cjj, cij = second_derivative(input, ci, cj)
155 beta = 1e-8
156 length = torch.sqrt(beta + ci ** 2 + cj ** 2)
157 curvature = (beta + ci ** 2) * cjj + \
158 (beta + cj ** 2) * cii - 2 * ci * cj * cij
159 curvature = torch.abs(curvature) / ((ci ** 2 + cj ** 2) ** 1.5 + beta)
160 elastica = torch.sum((a + b * (curvature ** 2)) * torch.abs(length))
161 return elastica
162
163 loss = region(y_pred, y_true, u=u) + elastica(y_pred, a=a, b=b)
164 return loss

Callers 1

ACELossFunction · 0.85

Calls 2

first_derivativeFunction · 0.85
second_derivativeFunction · 0.85

Tested by

no test coverage detected