Skip to content

Commit 4411826

Browse files
author
José Morano
committed
Properly formatted files
Signed-off-by: José Morano <[email protected]>
1 parent fc2f9cd commit 4411826

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

monai/losses/focal_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def focal_loss_with_probs(
274274

275275
# Compute focal loss components
276276
log_pt = torch.log(torch.clamp(pt, min=1e-8)) # Avoid log(0)
277-
focal_factor = (1 - pt).pow(gamma) # (1 - pt)**gamma
277+
focal_factor = (1 - pt).pow(gamma) # (1 - pt)**gamma
278278

279279
loss = -focal_factor * log_pt
280280

tests/losses/test_focal_loss.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ def test_bin_seg_3d(self):
311311
# The prediction here are probabilities, not logits.
312312
pred_very_good = target_one_hot.clone().float()
313313
else:
314-
pred_very_good = 1000 * F.one_hot(target, num_classes=num_classes).permute(0, 4, 1, 2, 3).float() - 500.0
314+
pred_very_good = (
315+
1000 * F.one_hot(target, num_classes=num_classes).permute(0, 4, 1, 2, 3).float() - 500.0
316+
)
315317

316318
# initialize the mean dice loss
317319
loss = FocalLoss(to_onehot_y=True, use_softmax=use_softmax, use_sigmoid=use_sigmoid)

0 commit comments

Comments
 (0)