runbenchmark_nni.sh 1.74 KB
Newer Older
Bill Wu's avatar
Bill Wu committed
1
2
3
4
5
#!/bin/bash

time=$(date "+%Y%m%d%H%M%S")
installation='automlbenchmark'
outdir="results_$time"
6
7
benchmark='nnivalid'      # 'nnismall' 'nnismall-regression' 'nnismall-binary' 'nnismall-multiclass' 
serialize=true           # if false, run all experiments together in background
Bill Wu's avatar
Bill Wu committed
8
9
10
11
12
13
14
15
16

mkdir $outdir $outdir/scorelogs $outdir/reports 

if [ "$#" -eq 0 ]; then
    tuner_array=('TPE' 'Random' 'Anneal' 'Evolution' 'GPTuner' 'MetisTuner' 'Hyperband')
else
    tuner_array=( "$@" )
fi

17
if [ "$serialize" = true ]; then
Bill Wu's avatar
Bill Wu committed
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
    # run tuners serially 
    for tuner in ${tuner_array[*]}; do
	echo "python $installation/runbenchmark.py $tuner $benchmark -o $outdir -u nni"
	python $installation/runbenchmark.py $tuner $benchmark -o $outdir -u nni
    done

    # parse final results
    echo "python parse_result_csv.py $outdir/results.csv"
    python parse_result_csv.py "$outdir/results.csv"

else
    # run all the tuners in background
    for tuner in ${tuner_array[*]}; do
	mkdir "$outdir/$tuner" "$outdir/$tuner/scorelogs"
	echo "python $installation/runbenchmark.py $tuner $benchmark -o $outdir/$tuner -u nni &"
	python $installation/runbenchmark.py $tuner $benchmark -o $outdir/$tuner -u nni &
    done
    
    wait

    # aggregate results
    touch "$outdir/results.csv"
    let i=0
    for tuner in ${tuner_array[*]}; do
	cp "$outdir/$tuner/scorelogs"/* $outdir/scorelogs
	if [ $i -eq 0 ]; then
	    cp "$outdir/$tuner/results.csv" "$outdir/results.csv"
	else
	    let nlines=`cat "$outdir/$tuner/results.csv" | wc -l`
	    ((nlines=nlines-1))
	    tail -n $nlines "$outdir/$tuner/results.csv" >> "$outdir/results.csv" 
	fi
	((i=i+1))
    done

    # parse final results
    echo "python parse_result_csv.py $outdir/results.csv"
    python parse_result_csv.py "$outdir/results.csv"
fi