我得到了caffe的结果,我将从中提取出最终的损失值。现在,我已经通过bash脚本获得了最终结果。例如,输出为:
I1221 15:29:03.581897 23416 solver.cpp:347] Iteration 300000, Testing net (#0) I1221 15:29:36.107956 23416 solver.cpp:415] Test net output #0: acc01 = 0.997557 I1221 15:29:36.108728 23416 solver.cpp:415] Test net output #1: acc02 = 0.799582 I1221 15:29:36.108815 23416 solver.cpp:415] Test net output #2: acc03 = 0.614063 I1221 15:29:36.108839 23416 solver.cpp:415] Test net output #3: acc04 = 0.875842 I1221 15:29:36.108880 23416 solver.cpp:415] Test net output #4: loss01 = 0.0183781 (* 1 = 0.0183781 loss) I1221 15:29:36.108914 23416 solver.cpp:415] Test net output #5: loss02 = 0.499269 (* 1 = 0.499269 loss) I1221 15:29:36.108945 23416 solver.cpp:415] Test net output #6: loss03 = 0.660662 (* 1 = 0.660662 loss) I1221 15:29:36.108974 23416 solver.cpp:415] Test net output #7: loss04 = 0.373288 (* 1 = 0.373288 loss) I1221 15:29:36.108996 23416 solver.cpp:332] Optimization Done. I1221 15:29:36.109011 23416 caffe.cpp:215] Optimization Done.
我会得到:
300000, 0.997557, 0.799582, 0.614063, 0.875842, 0.0183781, 0.499269, 0.660662, 0.373288
这是
Iteration, acc01, acc02, acc03, acc04, loss01, loss02, loss03, loss04
您能否指导我如何编写一些bash脚本来做到这一点。
谢谢,
阿夫申
最佳答案
awk方法..希望您喜欢awk!
awk -v value="" '{for(i=1;i<=NF;++i){if($i~/^acc/){value=value " " $(i+2)}else if($i~/^Iteration/){value=value $(i+1)}};print value}' my_file
关于linux - 使用bash脚本从Linux中的文本获取一些报告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34426224/