-
Notifications
You must be signed in to change notification settings - Fork 1
/
evaluate.py
24 lines (19 loc) · 895 Bytes
/
evaluate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from run import Runner
import sys
import torch
def evaluate(config_name, gpu_id, saved_suffix):
runner = Runner(config_name, gpu_id)
model = runner.initialize_model(saved_suffix)
examples_train, examples_dev, examples_test = runner.data.get_tensor_examples()
stored_info = runner.data.get_stored_info()
runner.evaluate(
model, examples_dev, stored_info, 0, official=False, conll_path=runner.config['conll_eval_path'], predict=True
) # Eval dev
# print('=================================')
# runner.evaluate(model, examples_test, stored_info, 0, official=False, conll_path=runner.config['conll_test_path']) # Eval test
if __name__ == '__main__':
config_name, saved_suffix, gpu_id = sys.argv[1], sys.argv[2], int(sys.argv[3])
evaluate(config_name, gpu_id, saved_suffix)
print(
torch.cuda.max_memory_allocated(device=gpu_id)
)