-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from sguada/parselog
Polish log parsing script
- Loading branch information
Showing
1 changed file
with
9 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
#!/bin/bash | ||
# Usage parselog.sh caffe.log [init_iter=0] [test_interval=1000] | ||
# Usage parselog.sh caffe.log | ||
# It creates two files one caffe.log.test that contains the loss and test accuracy of the test and | ||
# another one caffe.log.loss that contains the loss computed during the training | ||
# Use init_iter when the log start from a previous snapshot | ||
# Use test_interval when the testing interval is different than 1000 | ||
|
||
if [ "$#" -lt 1 ] | ||
then | ||
echo "Usage parselog.sh /path_to/caffe.log [init_iter=0] [test_interval=1000]" | ||
fi | ||
if [ "$#" -gt 1 ] | ||
then | ||
INIT=$2 | ||
else | ||
INIT=0 | ||
fi | ||
if [ "$#" -gt 2 ] | ||
then | ||
INC=$3 | ||
else | ||
INC=1000 | ||
echo "Usage parselog.sh /path_to/caffe.log" | ||
fi | ||
LOG=`basename $1` | ||
grep 'Test score #0' $1 | awk -v init=$INIT -v inc=$INC '{print (NR*inc+init), $8}' > aux0.txt | ||
grep 'Test score #1' $1 | awk '{print $8}' > aux1.txt | ||
grep -B 2 'Test ' $1 > aux.txt | ||
grep 'Iteration ' aux.txt | sed 's/.*Iteration \([[:digit:]]*\).*/\1/g' > aux0.txt | ||
grep 'Test score #0' aux.txt | awk '{print $8}' > aux1.txt | ||
grep 'Test score #1' aux.txt | awk '{print $8}' > aux2.txt | ||
grep ' loss =' $1 | awk '{print $6,$9}' | sed 's/,//g' | column -t > $LOG.loss | ||
paste aux0.txt aux1.txt | column -t > $LOG.test | ||
rm aux0.txt aux1.txt | ||
paste aux0.txt aux1.txt aux2.txt | column -t > $LOG.test | ||
rm aux.txt aux0.txt aux1.txt aux2.txt |