We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a340e60 commit 96a52d3Copy full SHA for 96a52d3
2 files changed
pymic/loss/cls/ce.py
@@ -38,7 +38,7 @@ def forward(self, loss_input_dict):
38
predict = loss_input_dict['prediction']
39
labels = loss_input_dict['ground_truth']
40
# for numeric stability
41
- predict = nn.Sigmoid()(predict) * 0.999 + 0.0005
+ predict = nn.Sigmoid()(predict) * 0.999 + 5e-4
42
loss = - labels * torch.log(predict) - (1 - labels) * torch.log( 1 - predict)
43
loss = loss.mean()
44
return loss
pymic/loss/seg/ce.py
@@ -25,6 +25,8 @@ def forward(self, loss_input_dict):
25
predict = reshape_tensor_to_2D(predict)
26
soft_y = reshape_tensor_to_2D(soft_y)
27
28
+ # for numeric stability
29
+ predict = predict * 0.999 + 5e-4
30
ce = - soft_y* torch.log(predict)
31
if(self.enable_cls_weight):
32
if(cls_w is None):
0 commit comments