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

Commit

Permalink
Merge pull request #8 from junweima/fix
Browse files Browse the repository at this point in the history
fix 0 percent training accuracy
  • Loading branch information
ynd authored Sep 8, 2018
2 parents 7af1916 + 044c560 commit eaff31a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def train(epoch):
train_loss += loss.data[0]
_, predicted = torch.max(outputs.data, 1)
total += targets.size(0)
correct += (lam * predicted.eq(targets_a.data).cpu().sum()
+ (1 - lam) * predicted.eq(targets_b.data).cpu().sum())
correct += (lam * predicted.eq(targets_a.data).cpu().sum().float()
+ (1 - lam) * predicted.eq(targets_b.data).cpu().sum().float())

optimizer.zero_grad()
loss.backward()
Expand Down

0 comments on commit eaff31a

Please sign in to comment.