Skip to content

Commit

Permalink
Add criterion for checking valid weighing factor
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 committed Jul 10, 2024
1 parent f2bd62e commit 47b191f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions micro_sam/training/semantic_sam_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def __init__(
self.num_classes = num_classes
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."

self._kwargs = kwargs

def _compute_loss(self, y, masks):
Expand Down

0 comments on commit 47b191f

Please sign in to comment.