MCPcopy Create free account
hub / github.com/649453932/Chinese-Text-Classification-Pytorch / test

Function test

train_eval.py:83–96  ·  view source on GitHub ↗
(config, model, test_iter)

Source from the content-addressed store, hash-verified

81
82
83def 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
99def evaluate(config, model, data_iter, test=False):

Callers 1

trainFunction · 0.85

Calls 2

get_time_difFunction · 0.90
evaluateFunction · 0.85

Tested by

no test coverage detected