Skip to content

Commit

Permalink
debug maskdino (#250)
Browse files Browse the repository at this point in the history
Avoid fp16 overflow.
  • Loading branch information
HaoZhang534 authored Apr 7, 2023
1 parent cd2fb80 commit b978bf2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/maskdino/modeling/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def memory_efficient_forward(self, outputs, targets, cost=["cls", "box", "mask"]
# focal loss
alpha = 0.25
gamma = 2.0
neg_cost_class = (1 - alpha) * (out_prob ** gamma) * (-(1 - out_prob + 1e-8).log())
pos_cost_class = alpha * ((1 - out_prob) ** gamma) * (-(out_prob + 1e-8).log())
neg_cost_class = (1 - alpha) * (out_prob ** gamma) * (-(1 - out_prob + 1e-5).log())
pos_cost_class = alpha * ((1 - out_prob) ** gamma) * (-(out_prob + 1e-5).log())
cost_class = pos_cost_class[:, tgt_ids] - neg_cost_class[:, tgt_ids]

# Compute the classification cost. Contrary to the loss, we don't use the NLL,
Expand Down

0 comments on commit b978bf2

Please sign in to comment.