前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >caffe 的命令行训练与测试

caffe 的命令行训练与测试

作者头像
用户1148525
发布2019-05-26 11:55:38
1.5K0
发布2019-05-26 11:55:38
举报

本文转自: http://blog.csdn.net/yiliang_/article/details/60464968

Train训练(用cmd caffe命令行) (solver.prototxt) 在使用cmdcaffe时,需要默认切换到Caffe_Root文件夹下,需要使用上述命令才可以使用tools下的caffe接口,因为caffe默认都需要从根目录下面执行文件。 1、训练模型,以mnist为例子(solver.prototxt) ./build/tools/caffe train -solver=examples/mnist/lenet_solver.prototxt

保存训练日志 ./build/tools/caffe train -solver=examples/mnist/lenet_solver.prototxt 2>&1| tee /home/guest/caffe/examples/mnist/caffe200.log

从中断点的 snapshot 继续训练(solver.prototxt + .solverstate) ./build/tools/caffe train -solver examples/mnist/lenet_solver.prototxt -snapshot examples/mnist/lenet_iter_5000.solverstate

2、观察各个阶段的运行时间可以使用(train_test.prototxt) ./build/tools/caffe time -model examples/mnist/lenet_train_test.prototxt -iterations 10

3、使用已有模型提取特征(caffemodel + train_val.prototxt + fc7 + num_mini_batches) ./build/tools/extract_features.bin models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel examples/feature_extraction/train_val.prototxt fc7 examples/temp_features 10 lmdb

1) fc7表示提取全连接第七层特征,conv5表示提取第五个卷积层的特征, examples/temp_features表示存放结果的目录(目录不需要提前构建)

2.)10:输入的包的数量,我们test时的batchsize是50,这里输入10,表示会提取50*10=500张图片的特征

3.)imageNet网络有很多层(data conv1 conv2 conv3 conv4 conv5 fc6 fc7 fc8 prob),我们可以选取任意一层;fc7是最后一层特征,fc8输出的就是softmax的输出了,所以提取fc7层

4.)lmdb:输出的数据格式是lmdb,还可以是leveldb


Test测试(用cmdcaffe命令行)(train_test.prototxt + caffemodel) caffe test 命令通过在 test phase 中运行模型得到分数,并且用这分数表示网络输出的最终结果。网络结构必须被适当定义,生成accuracy或loss作为其结果。测试过程中,终端会显示每个 batch的得分,最后输出全部 batch 得分的平均值。 # 对于网络结构文件 lenet_train_test.prototxt所定义的网络 # 用 validation set 得到已训练的 image_test 模型的分数 ./build/tools/caffe test -model examples/image_test/train_val.prototxt -weights examples/image_test/caffenet_train/caffenet_train_iter_10000.caffemodel

Test分类单个输入图像

利用训练好的模型,预测结果,5个输入参数 (train_val.prototxt + caffemodel + mean.binaryproto + synset_words.txt + cat.jpg) test指定图像,输出结果 sudo ./build/examples/cpp_classification/classification.bin \ models/bvlc_reference_caffenet/deploy.prototxt \ models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel \ data/ilsvrc12/imagenet_mean.binaryproto \ data/ilsvrc12/synset_words.txt \ examples/images/cat.jpg

测试ilsvrc12 ./build/examples/cpp_classification/classification.bin \ models/bvlc_reference_caffenet/deploy.prototxt \ models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel \ data/ilsvrc12/imagenet_mean.binaryproto data/ilsvrc12/synset_words.txt examples/images/cat.jpg

———- Prediction for examples/images/cat.jpg ———- 0.3134 - “n02123045 tabby, tabby cat” 0.2380 - “n02123159 tiger cat” 0.1235 - “n02124075 Egyptian cat” 0.1003 - “n02119022 red fox, Vulpes vulpes” 0.0715 - “n02127052 lynx, catamount”

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年07月26日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档