-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner_ckpt.py
52 lines (39 loc) 路 1.11 KB
/
runner_ckpt.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import argparse
from runner import run_glue, TASKS
from pathlib import Path
from gather_scores import gather_scores, pretty_print
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'model_paths',
nargs='+',
help='Path(s) to pre-trained model checkpoints.'
)
parser.add_argument(
'--gpu_idx',
default='0',
help='GPU index, as used in CUDA_VISIBLE_DEVICES.'
)
parser.add_argument(
'--task',
choices=TASKS
)
args = parser.parse_args()
glue_out_paths = []
for model_path in args.model_paths:
output_dir = Path(model_path) / 'glue'
run_glue(
model_path=model_path,
task=args.task,
output_dir_task=output_dir / args.task,
gpu_idx=args.gpu_idx,
do_train=False
)
glue_out_paths.append(output_dir)
print("\n========== Finished ==========\n")
for path in glue_out_paths:
print(f"\n\nModel:\n{path}")
scores = gather_scores(path)
pretty_print(scores)
if __name__ == '__main__':
main()