(y_pred, y_true, u=1)
| 140 | return cii, cjj, cij |
| 141 | |
| 142 | def region(y_pred, y_true, u=1): |
| 143 | label = y_true.float() |
| 144 | c_in = torch.ones_like(y_pred) |
| 145 | c_out = torch.zeros_like(y_pred) |
| 146 | region_in = torch.abs(torch.sum(y_pred * ((label - c_in) ** 2))) |
| 147 | region_out = torch.abs( |
| 148 | torch.sum((1 - y_pred) * ((label - c_out) ** 2))) |
| 149 | region = u * region_in + region_out |
| 150 | return region |
| 151 | |
| 152 | def elastica(input, a=1, b=1): |
| 153 | ci, cj = first_derivative(input) |