|
77 | 77 | best_dev_acc = -1 |
78 | 78 | header = ' Time Epoch Iteration Progress (%Epoch) Loss Dev/Loss Accuracy Dev/Accuracy' |
79 | 79 | dev_log_template = ' '.join( |
80 | | - '{:>6.0f},{:>5.0f},{:>9.0f},{:>5.0f}/{:<5.0f} {:>7.0f}%,{:>8.6f},{:8.6f},{:12.4f},{:12.4f}'. |
81 | | - split(',')) |
| 80 | + '{:>6.0f},{:>5.0f},{:>9.0f},{:>5.0f}/{:<5.0f} {:>7.0f}%,{:>8.6f},{:8.6f},{:12.4f},{:12.4f}' |
| 81 | + .split(',')) |
82 | 82 | log_template = ' '.join( |
83 | 83 | '{:>6.0f},{:>5.0f},{:>9.0f},{:>5.0f}/{:<5.0f} {:>7.0f}%,{:>8.6f},{},{:12.4f},{}'.split(',')) |
84 | 84 | makedirs(args.save_path) |
|
108 | 108 | answer = model(premise_batch, hypothesis_batch) |
109 | 109 |
|
110 | 110 | # calculate accuracy of predictions in the current batch |
111 | | - n_correct += (torch.max(answer, |
112 | | - 1)[1].view(label_batch.size()) == label_batch).sum() |
| 111 | + n_correct += (torch.max(answer, 1)[1].view(label_batch.size()) == label_batch).sum() |
113 | 112 | n_total += premise_batch.size()[1] |
114 | 113 | train_acc = 100. * n_correct / n_total |
115 | 114 |
|
|
150 | 149 | for dev_batch_idx, (premise_batch, hypothesis_batch, |
151 | 150 | label_batch) in enumerate(dev_iterator): |
152 | 151 | answer = model(premise_batch, hypothesis_batch) |
153 | | - n_dev_correct += (torch.max(answer, 1)[1].view( |
154 | | - label_batch.size()) == label_batch).sum() |
| 152 | + n_dev_correct += (torch.max(answer, |
| 153 | + 1)[1].view(label_batch.size()) == label_batch).sum() |
155 | 154 | dev_loss = criterion(answer, label_batch) |
156 | 155 | dev_acc = 100. * n_dev_correct / len(dev) |
157 | 156 |
|
|
0 commit comments