(config, model, test_iter)
| 81 | |
| 82 | |
| 83 | def test(config, model, test_iter): |
| 84 | # test |
| 85 | model.load_state_dict(torch.load(config.save_path)) |
| 86 | model.eval() |
| 87 | start_time = time.time() |
| 88 | test_acc, test_loss, test_report, test_confusion = evaluate(config, model, test_iter, test=True) |
| 89 | msg = 'Test Loss: {0:>5.2}, Test Acc: {1:>6.2%}' |
| 90 | print(msg.format(test_loss, test_acc)) |
| 91 | print("Precision, Recall and F1-Score...") |
| 92 | print(test_report) |
| 93 | print("Confusion Matrix...") |
| 94 | print(test_confusion) |
| 95 | time_dif = get_time_dif(start_time) |
| 96 | print("Time usage:", time_dif) |
| 97 | |
| 98 | |
| 99 | def evaluate(config, model, data_iter, test=False): |
no test coverage detected