Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit eaff31a

Browse files
authored
Merge pull request #8 from junweima/fix
fix 0 percent training accuracy
2 parents 7af1916 + 044c560 commit eaff31a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def train(epoch):
158158
train_loss += loss.data[0]
159159
_, predicted = torch.max(outputs.data, 1)
160160
total += targets.size(0)
161-
correct += (lam * predicted.eq(targets_a.data).cpu().sum()
162-
+ (1 - lam) * predicted.eq(targets_b.data).cpu().sum())
161+
correct += (lam * predicted.eq(targets_a.data).cpu().sum().float()
162+
+ (1 - lam) * predicted.eq(targets_b.data).cpu().sum().float())
163163

164164
optimizer.zero_grad()
165165
loss.backward()

0 commit comments

Comments
 (0)