Skip to content

Commit c5f70e0

Browse files
authored
Update dice weight constraints for flexible loss weighting (#839)
1 parent 84dc87d commit c5f70e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

micro_sam/training/semantic_sam_trainer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def __init__(self, convert_inputs, num_classes: int, dice_weight: Optional[float
7070
self.compute_ce_loss = nn.CrossEntropyLoss()
7171
self.dice_weight = dice_weight
7272

73-
if self.dice_weight is not None:
74-
assert self.dice_weight > 0 and self.dice_weight < 1, "The weight factor should lie between 0 and 1."
73+
if self.dice_weight is not None and (self.dice_weight < 0 or self.dice_weight > 1):
74+
raise ValueError("The weight factor should lie between 0 and 1.")
7575

7676
self._kwargs = kwargs
7777

0 commit comments

Comments
 (0)