Skip to content

Instantly share code, notes, and snippets.

@Logrus
Created November 21, 2016 18:22
Show Gist options
  • Save Logrus/16412952fc890f16f289de3d8e08fd2c to your computer and use it in GitHub Desktop.
Save Logrus/16412952fc890f16f289de3d8e08fd2c to your computer and use it in GitHub Desktop.
plot_loss_py.sh
#!/bin/bash
cat *log | grep -o ".Loss.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*" > loss_values.txt
num=51
if [ $# -eq 1 ]; then
num=$1
fi
python -c "import numpy as np; from scipy.signal import savgol_filter; y=np.loadtxt('loss_values.txt'); yh=savgol_filter(y, $num, 3); np.savetxt('smoothed_values.txt',yh);"
(
gnuplot <<- EOF
set terminal jpeg
set xlabel "Iterations"
set ylabel "Loss"
set style line 1 lt 1 pt 1 lw 2 lc rgb "blue"
plot "smoothed_values.txt" ls 1
EOF
) > smoothed_loss.jpg
xdg-open smoothed_loss.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment