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

Method forward

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

Source from the content-addressed store, hash-verified

66 self.classes = classes
67
68 def forward(self, predication, label):
69 min_pool_x = nn.functional.max_pool2d(
70 predication * -1, (3, 3), 1, 1) * -1
71 contour = torch.relu(nn.functional.max_pool2d(
72 min_pool_x, (3, 3), 1, 1) - min_pool_x)
73
74 # length
75 length = torch.sum(torch.abs(contour))
76
77 # region
78 label = label.float()
79 c_in = torch.ones_like(predication)
80 c_out = torch.zeros_like(predication)
81 region_in = torch.abs(torch.sum(predication * ((label - c_in) ** 2)))
82 region_out = torch.abs(
83 torch.sum((1 - predication) * ((label - c_out) ** 2)))
84 region = self.miu * region_in + region_out
85
86 return region + length
87
88
89def ACELoss(y_pred, y_true, u=1, a=1, b=1):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected