/
format_accuracy_for_plot.sh
executable file
·51 lines (49 loc) · 1.65 KB
/
format_accuracy_for_plot.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
## Joshua Meyer 2018
##
## format logged training data from compute_prob_valid.* and
## compute_prob_train.* so that the scipt utils/plot_accuracy.py
## and matplotlib can work with it.
LOGDIR=$1
NNET=$2
OUTPUT=$3
if [ $NNET == "nnet2" ]; then
## NNET2 ##
# loop over validation data logs
for i in ${LOGDIR}/compute_prob_valid.*; do
trial=(${i//./ });
trial=${trial[1]};
grep -oP 'accuracy is [0-9]\.[0-9]+' $i | while read -r match; do
myarray=($match);
echo "valid" "'output-0'" "$trial" "${myarray[2]}" >> $OUTPUT;
done
done
# loop over training data logs
for i in ${LOGDIR}/compute_prob_train.*; do
trial=(${i//./ });
trial=${trial[1]};
grep -oP 'accuracy is [0-9]\.[0-9]+' $i | while read -r match; do
myarray=($match);
echo "train" "'output-0'" "$trial" "${myarray[2]}" >> $OUTPUT;
done
done
elif [ $NNET == "nnet3" ]; then
## NNET3 ##
# loop over validation data logs
for i in ${LOGDIR}/compute_prob_valid.*; do
trial=(${i//./ });
trial=${trial[1]}
grep -oP '(?<=accuracy for).+(?= per frame)' $i | while read -r match; do
myarray=($match);
echo "valid" "${myarray[0]}" "$trial" "${myarray[2]}" >> $OUTPUT;
done
done
# loop over training data logs
for i in ${LOGDIR}/compute_prob_train.*; do
trial=(${i//./ });
trial=${trial[1]};
grep -oP '(?<=accuracy for).+(?= per frame)' $i | while read -r match; do
myarray=($match);
echo "train" "${myarray[0]}" "$trial" "${myarray[2]}" >> $OUTPUT;
done
done
fi