Skip to content

Instantly share code, notes, and snippets.

@mateuszbuda
Last active January 31, 2017 17:53
Show Gist options
  • Save mateuszbuda/3a90ea3059396cd362240810f31bf223 to your computer and use it in GitHub Desktop.
Save mateuszbuda/3a90ea3059396cd362240810f31bf223 to your computer and use it in GitHub Desktop.
Generates plot from caffe training log file
#!/bin/bash
if [ "${1}" == "loss" ]; then
D=5
elif [ "${1}" == "accuracy" ]; then
D=4
else
echo "First argument should be either loss or accuracy"
exit 1
fi
# generate csv files from log
DIR=$(dirname "${2}")
python2 $CAFFE_ROOT/tools/extra/parse_log.py $2 ${DIR}
# plot
train_file=${2}.train
test_file=${2}.test
gnuplot_cmd="set key left top; set datafile separator ','; plot '${train_file}' using 1:${D} with line title '${1} train', '${test_file}' using 1:${D} with line title '${1} test';"
# osx to display (requires: brew install gnuplot --with-x11)
#gnuplot_cmd="set terminal x11; set key left top; set datafile separator ','; plot '${train_file}' using 1:${D} with line title '${1} train', '${test_file}' using 1:${D} with line title '${1} test';"
# osx to save to accuracy.png file
#gnuplot_cmd="set terminal png; set output \"./accuracy.png\"; set key left top; set datafile separator ','; plot '${train_file}' using 1:${D} with line title '${1} train', '${test_file}' using 1:${D} with line title '${1} test';"
gnuplot -p -e "${gnuplot_cmd}"
unset D
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment