(self, predication, label)
| 207 | self.diff_z.weight = self.sobel_z |
| 208 | |
| 209 | def forward(self, predication, label): |
| 210 | grd_x = self.diff_x(predication) |
| 211 | grd_y = self.diff_y(predication) |
| 212 | grd_z = self.diff_z(predication) |
| 213 | |
| 214 | # length |
| 215 | length = torch.sqrt(grd_x ** 2 + grd_y ** 2 + grd_z ** 2 + 1e-8) |
| 216 | length = (length - length.min()) / (length.max() - length.min() + 1e-8) |
| 217 | length = torch.sum(length) |
| 218 | |
| 219 | # region |
| 220 | label = label.float() |
| 221 | c_in = torch.ones_like(predication) |
| 222 | c_out = torch.zeros_like(predication) |
| 223 | region_in = torch.abs(torch.sum(predication * ((label - c_in) ** 2))) |
| 224 | region_out = torch.abs( |
| 225 | torch.sum((1 - predication) * ((label - c_out) ** 2))) |
| 226 | region = region_in + region_out |
| 227 | |
| 228 | return self.alpha * region + length |
| 229 | |
| 230 | |
| 231 | class ACLoss3DV2(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected