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

Method forward

aceloss.py:243–261  ·  view source on GitHub ↗
(self, predication, label)

Source from the content-addressed store, hash-verified

241 self.classes = classes
242
243 def forward(self, predication, label):
244 min_pool_x = nn.functional.max_pool3d(
245 predication * -1, (3, 3, 3), 1, 1) * -1
246 contour = torch.relu(nn.functional.max_pool3d(
247 min_pool_x, (3, 3, 3), 1, 1) - min_pool_x)
248
249 # length
250 length = torch.sum(torch.abs(contour))
251
252 # region
253 label = label.float()
254 c_in = torch.ones_like(predication)
255 c_out = torch.zeros_like(predication)
256 region_in = torch.abs(torch.sum(predication * ((label - c_in) ** 2)))
257 region_out = torch.abs(
258 torch.sum((1 - predication) * ((label - c_out) ** 2)))
259 region = self.miu * region_in + region_out
260
261 return region + length
262
263
264class ACELoss3D(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected