-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLM_F.sh
52 lines (41 loc) · 1.42 KB
/
LM_F.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
#!/bin/bash
set -u
trap 'echo Abort; exit' INT TERM
if [ $# -lt 1 ]; then
echo "usage: $(basename $0) <dest> <n_threads>" >&2
exit 0
fi
BASE=$(dirname $0)
ROOT=$BASE/../..
DEST=${1?Missing DEST}
N_THREADS=${2?Missing N_THREADS}
mkdir -p $DEST/{runs,models,eval_results}
run_cascade_cv() {
alphas="$1"
strategy=default
echo $alphas
for i in 1 2 3 4 5; do
tag="gov2.LM_F.f${i}.alpha=$alphas"
python $ROOT/python/Cascade.py train $strategy \
$BASE/data/{train,valid,test}-f${i}.npz \
$BASE/data/{costs,importance}.txt \
--n_stages 3 --cutoffs '[None,1000,100]' --alpha "$alphas" \
--epochs 10 --model_prefix "$DEST/models/model.$tag"
python $ROOT/python/Cascade.py predict \
$BASE/data/{valid-f${i}.npz,costs.txt} \
"$DEST/models/model.$tag" \
--output_eval "$DEST/eval_results/valid.$tag"
python $ROOT/python/Cascade.py predict \
$BASE/data/{test-f${i}.npz,costs.txt} \
"$DEST/models/model.$tag" \
--output_trec_run "$DEST/runs/run.$tag" \
--output_eval "$DEST/eval_results/test.$tag"
done
cat $DEST/runs/run.gov2.LM_F.f{1,2,3,4,5}."alpha=$alphas" \
| python $BASE/cut_to_1000.py \
> $DEST/runs/run.gov2.LM_F.all."alpha=$alphas"
}
export -f run_cascade_cv
export BASE ROOT DEST
which parallel >/dev/null || { echo "error: GNU parallel is not installed" >&2; }
parallel -j$N_THREADS run_cascade_cv {} ::: $(python $BASE/gen_alphas.py -small -e 500)