+
+######################################################################
+# Plot the loss curves if gnuplot is here
+
+if [[ $(which gnuplot) ]]; then
+ echo "Plotting losses.pdf."
+
+ TERMINAL="pdfcairo color transparent enhanced font \"Times,14\""
+ EXTENSION="pdf"
+
+ gnuplot <<EOF
+set terminal ${TERMINAL}
+set output "${DYNCNN_RESULT_DIR}/losses.${EXTENSION}"
+set logscale x
+set logscale y
+set size ratio 0.75
+set xlabel "Number of epochs"
+set ylabel "Loss"
+plot '< grep "LOSS " "${DYNCNN_RESULT_DIR}"/log' using 2:4 with l lw 3 lc rgb '#c0c0ff' title 'Validation loss',\
+ '< grep "LOSS " "${DYNCNN_RESULT_DIR}"/log' using 2:3 with l lw 1 lc rgb '#000000' title 'Train loss'
+
+EOF
+
+fi
+
+######################################################################