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

Commit

Permalink
fix 0 percent training accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
junweima committed Sep 7, 2018
1 parent 7af1916 commit 044c560
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 044c560

Please sign in to comment.