Skip to content

Commit

Permalink
Update dice weight constraints for flexible loss weighting (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 authored Jan 19, 2025
1 parent 84dc87d commit c5f70e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions micro_sam/training/semantic_sam_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def __init__(self, convert_inputs, num_classes: int, dice_weight: Optional[float
self.compute_ce_loss = nn.CrossEntropyLoss()
self.dice_weight = dice_weight

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

self._kwargs = kwargs

Expand Down

0 comments on commit c5f70e0

Please sign in to comment.