-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_experiments.sh
90 lines (77 loc) · 2.18 KB
/
run_experiments.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# getting all the parameters
root_dir=$1
par_temp=$2
data_dir=$3
target_classes=$4
run_id=$5
run_num=$6
nqueries=$7
chunk=$8
optpars=$9
echo "Input Directories"
echo "================================="
echo "Root dir: $root_dir"
echo "Par. template: $par_temp"
echo "Data dir: $data_dir"
echo "Target classes: $target_classes"
echo "Input Parameters"
echo "================================="
echo "Run ID: $run_id"
echo "# Runs: $run_num"
echo "# queries: $nqueries"
echo "Iter-chunk: $chunk"
echo "Parameters: $optpars"
echo "================================="
# if this experiment does not exist,
# create one and set the parameters
if [ ! -d $root_dir ]; then
echo "Creating experiment in:"
echo $root_dir
# creating the experiment
python -c "from expr_handler import create_expr; create_expr('$root_dir','$data_dir','$target_classes')"
# setting up the parameters
python -c "from expr_handler import set_parameters; set_parameters('$par_temp', '$root_dir', '$optpars')"
fi
# checking if the given run-ID is a number
# or a plust ('+') as a sign to add a run
re='^[0-9]+$'
if [[ $run_id =~ $re ]]; then
# if so, do not run more tan once
run_num=1
fi
for ((i=1;i<=$run_num;i++))
do
# and now run the experiment
M=(fi random entropy rep-entropy)
# print the parameters
python -c "import expr_handler; import AL; E=AL.Experiment('$root_dir'); expr_handler.print_parameters(E)"
# if it's a new run create it
if ! [[ $run_id =~ $re ]]; then
# creating the new run in the experiment
python -c "from expr_handler import create_run; create_run('$root_dir')"
# assiginig the run ID
run_id=`python -c "import AL;E=AL.Experiment('$root_dir');print(len(E.get_runs())-1)"`
echo ""
echo "This new run's ID is $run_id"
fi
# for each method run the querying iterations
# chunk-by-chunk
for method in ${M[@]}
do
Q=0
while [ $Q -lt $(($nqueries)) ]
do
echo "Running method $method"
python expr_handler.py \
$root_dir \
$run_id \
$method \
$chunk
# update the counter
Q=$(($Q+$chunk))
done
done
# if the iteration is supposed to repeat
# turn "run_id" back to '+' symbol
run_id=+
done