forked from extreme-bert/extreme-bert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect_best_val.sh
executable file
·67 lines (54 loc) · 2.45 KB
/
collect_best_val.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Copyright 2022 Statistics and Machine Learning Research Group at HKUST. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function main() {
local task_name
# ===== Test setting
# local pretrain_dataset_name="bookcorpus-evenly-article-partition"
# ===== Standard finetune setting
local pretrain_dataset_name=$1
local prefix=$2
local model_set_path="saved_models/pretrain/${pretrain_dataset_name}"
local epoch_pattern="epoch-.*"
for task_name in wnli rte mrpc stsb cola sst2 qnli qqp mnli; do
# for task_name in wnli; do
# Collects best validation results
for model_path in ${model_set_path}/${prefix}; do
local model_name=$(basename ${model_path})
local input_file="log/finetune/${pretrain_dataset_name}/${task_name}/${model_name}/summary.log"
local output_file="log/finetune/${pretrain_dataset_name}/${task_name}/${model_name}/best-val.log"
echo "${task_name}: collect best results to '${output_file}'..." >&2
# Heading bar: the meaning of metrics
echo "$(head -1 ${input_file} | tr -d '\n') pretrain_setting" \
| sed 's/ / /g' > ${output_file}
# Best validation results
cat ${input_file} | grep "${epoch_pattern}" | head -1 >> ${output_file}
done
# Displays heading + metrics meanings
echo "===== ${task_name}"
for model_path in ${model_set_path}/${prefix}; do
local model_name=$(basename ${model_path})
local output_file="log/finetune/${pretrain_dataset_name}/${task_name}/${model_name}/best-val.log"
cat ${output_file} | head -1
break # only display metric meanings once
done
# Displays best validation results
for model_path in ${model_set_path}/${prefix}; do
local model_name=$(basename ${model_path})
local output_file="log/finetune/${pretrain_dataset_name}/${task_name}/${model_name}/best-val.log"
echo "$(cat ${output_file} | head -2 | tail -1) ${model_name}"
done
done
}
main "$@"