-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·66 lines (55 loc) · 1.78 KB
/
run.sh
File metadata and controls
executable file
·66 lines (55 loc) · 1.78 KB
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
#!/bin/bash
ROOT=`pwd`
PROBLEM="$1"
LAMBDAS=($(python3 -c "import numpy; print(*map(lambda x: f'{x:.3f}', numpy.logspace(0,1,21)))"))
SAMPLER_ARGS="num_warmup=1000 num_samples=10000"
ISVI_ARGS="num_warmup=1000 stochastic_kl=1 num_samples=10000 num_kl_samples=50 adapt delta=0.8"
CMDSTAN="$ROOT/cmdstan"
REFRESH=500
CHAINS=(1 2 3 4)
if [ ! -f $ROOT/$PROBLEM/$PROBLEM ]; then
echo "$PROBLEM/$PROBLEM does not exist - maybe needs to be compiled?"
exit 1
fi
cd $ROOT/$PROBLEM
if [ -f data.json ]; then
DATA_ARG="data file=data.json"
else
DATA_ARG=""
fi
COMMANDS=()
for c in ${CHAINS[@]}; do
# RUN NUTS
if [ ! -e nuts_${c}.csv ]; then
echo "Running nuts_${c}.csv"
COMMANDS+=("./$PROBLEM sample $SAMPLER_ARGS $DATA_ARG output file=nuts_${c}.csv refresh=${REFRESH}")
else
echo "Skipping nuts_${c}.csv"
fi
# RUN ADVI
if [ ! -e advi_${c}.csv ]; then
echo "Running advi_${c}.csv"
COMMANDS+=("./$PROBLEM variational $DATA_ARG output file=advi_${c}.csv > /dev/null")
else
echo "Skipping advi_${c}.csv"
fi
done
# RUN OURS (ISVI), FOR EACH VALUE OF LAMBDA
for l in ${LAMBDAS[@]}; do
for c in ${CHAINS[@]}; do
if [ ! -e isvi_${l}_${c}.csv ]; then
echo "Running isvi_${l}_${c}.csv"
COMMANDS+=("./$PROBLEM isvi lambda=${l} $ISVI_ARGS $DATA_ARG output file=isvi_${l}_${c}.csv refresh=${REFRESH}")
else
echo "Skipping isvi_${l}_${c}.csv"
fi
done
done
# COMMANDS COLLECTED - NOW ACTUALLY DO THE RUNNING
parallel --jobs=12 --linebuffer ::: "${COMMANDS[@]}"
# Summarize stats for NUTS and ISVI
$CMDSTAN/bin/stansummary nuts*.csv > nuts_stats.txt
for l in ${LAMBDAS[@]}; do
# Summarize stats for ISVI across all chains
$CMDSTAN/bin/stansummary isvi_${l}_*.csv > isvi_${l}_stats.txt
done