加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 大数据 > 正文

DeepLearning: 数据处理4:将caffe训练时屏幕输出保存到文本文件

发布时间:2021-03-16 05:49:13 所属栏目:大数据 来源:网络整理
导读:Tips:代码中路径记得自己替换就行了。。。 1.训练次数比较多 的时候,屏幕好多信息可能没有及时看到,所以需呀把屏幕所有的输出都保存下来。 #!/usr/bin/env sh # 删除路径下的txt文件 rm -vf ~/lilai/myDL/clothes/mymodel/model/*.txt # 运行caffe,并将屏

Tips:代码中路径记得自己替换就行了。。。

1.训练次数比较多 的时候,屏幕好多信息可能没有及时看到,所以需呀把屏幕所有的输出都保存下来。

#!/usr/bin/env sh 
# 删除路径下的txt文件
rm -vf ~/lilai/myDL/clothes/mymodel/model/*.txt

# 运行caffe,并将屏幕输出信息结果保存到指定的txt文件中
sh train.sh 2>&1 | tee ~/lilai/myDL/clothes/mymodel/model/2016.4.17_22.04.txt

2.有时候,我们只需要更具体的损失和准确率,其他的都不需要。所以可以利用gerp正则和管道,提取我们自己需要的信息。这里只是个示范,具体的结合自己的使用就行了。。。

#!/usr/bin/env sh 
# 删除路径下的txt文件
rm -vf ~/lilai/myDL/clothes/mymodel/model/*.txt

# 运行caffe,并将屏幕输出信息结果保存到指定的txt文件中
sh train.sh 2>&1 | tee ~/lilai/myDL/clothes/mymodel/model/2016.txt

# 判定上一条语句执行是否成功,成功则$? = 0
if [ $? -eq 0 ] ; then 

# 统计测试准确率
echo "测试迭代次数:" > Test_accuracy.txt
grep -c 'accuracy =' 2016.txt >> Test_accuracy.txt
echo "测试迭代间隔:" >> Test_accuracy.txt
grep 'test_interval:' 2016.txt | cut -d ' ' -f 2 >> Test_accuracy.txt
echo ' ' >> Test_accuracy.txt
grep 'accuracy =' 2016.txt | cut -d '#' -f 2 | cut -d ' ' -f 2,3,4 >> Test_accuracy.txt

# 统计训练损失
echo "训练迭代次数:" >Train_loss.txt
grep -c 'Train net output #0: loss = ' 2016.txt >> Train_loss.txt
echo "训练迭代间隔:" >> Train_loss.txt
grep 'display' 2016.txt  | cut -d ' ' -f 2 >> Train_loss.txt
echo ' ' >> Train_loss.txt
grep 'Train net output #0: loss = ' 2016.txt | cut -d ':' -f 5 | cut -d '(' -f 1 | cut -d ' ' -f 2,4 >> Train_loss.txt

# 统计测试损失
echo "测试迭代次数:" >Test_loss.txt
grep -c 'Test net output #1: loss = ' 2016.txt >> Test_loss.txt
echo "测试迭代间隔:" >> Test_loss.txt
grep 'test_interval:' 2016.txt | cut -d ' ' -f 2 >> Test_loss.txt
echo ' ' >> Test_loss.txt
grep 'Test net output #1: loss = ' 2016.txt | cut -d '#' -f 2 | cut -d ' ' -f 2,4 >> Test_loss.txt

# 移动相关文件到指定路径
mv Test_accuracy.txt ~/lilai/myDL/clothes/mymodel/model/
mv Train_loss.txt ~/lilai/myDL/clothes/mymodel/model
mv Test_loss.txt ~/lilai/myDL/clothes/mymodel/model

fi

echo "测试 训练 Accuracy Loss 统计完毕!"

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读