(self, input, a=1, b=1)
| 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) + \ |
no test coverage detected