Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit 41c47b3

Browse files
committed
fix undefined variable
1 parent ce15f45 commit 41c47b3

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

FocalLoss/FocalLoss.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ def __init__(self, num_class, alpha=None, gamma=2, balance_index=-1, smooth=None
4545
raise ValueError('smooth value should be in [0,1]')
4646

4747
def forward(self, logit, target):
48-
49-
# logit = F.softmax(input, dim=1)
5048

5149
if logit.dim() > 2:
5250
# N,C,d1,d2 -> N,C,m (m=d1*d2*...)
@@ -55,14 +53,10 @@ def forward(self, logit, target):
5553
logit = logit.view(-1, logit.size(-1))
5654
target = target.view(-1, 1)
5755

58-
# N = input.size(0)
59-
# alpha = torch.ones(N, self.num_class)
60-
# alpha = alpha * (1 - self.alpha)
61-
# alpha = alpha.scatter_(1, target.long(), self.alpha)
6256
epsilon = 1e-10
6357
alpha = self.alpha
64-
if alpha.device != input.device:
65-
alpha = alpha.to(input.device)
58+
if alpha.device != logit.device:
59+
alpha = alpha.to(logit.device)
6660

6761
idx = target.cpu().long()
6862

0 commit comments

Comments
 (0)