Caffe部署中的几个train-test-solver-prototxt-deploy等说明三
Caffe部署中的几个train-test-solver-prototxt-deploy等说明<三>
转载地址: http://blog.csdn.net/lg1259156776/article/details/52550865
1:神经网络中,我们通过最小化神经网络来训练网络,所以在训练时最后一层是损失函数层(LOSS),
在测试时我们通过准确率来评价该网络的优劣,因此最后一层是准确率层(ACCURACY)。
但是当我们真正要使用训练好的数据时,我们需要的是网络给我们输入结果,对于分类问题,我们需要获得分类结果,如下右图最后一层我们得到
的是概率,我们不需要训练及测试阶段的LOSS,ACCURACY层了。
下图是能过$CAFFE_ROOT/Python/draw_net.py绘制$CAFFE_ROOT/models/caffe_reference_caffnet/train_val.prototxt , $CAFFE_ROOT/models/caffe_reference_caffnet/deploy.prototxt,分别代表训练时与最后使用时的网络结构。
我们一般将train与test放在同一个.prototxt中,需要在data层输入数据的source,
而在使用时.prototxt只需要定义输入图片的大小通道数据参数即可,如下图所示,分别是
$CAFFE_ROOT/models/caffe_reference_caffnet/train_val.prototxt , $CAFFE_ROOT/models/caffe_reference_caffnet/deploy.prototxt的data层
训练时, solver.prototxt中使用的是rain_val.prototxt
- ./build/tools/caffe/train -solver ./models/bvlc_reference_caffenet/solver.prototxt
使用上面训练的网络提取特征,使用的网络模型是deploy.prototxt
- ./build/tools/extract_features.bin models/bvlc_refrence_caffenet.caffemodel models/bvlc_refrence_caffenet/deploy.prototxt
2:
*_train_test.prototxt文件:这是训练与测试网络配置文件
deploy.prototxt文件书写:
注意在输出层的类型发生了变化一个是SoftmaxWithLoss,另一个是Softmax。另外为了方便区分训练与应用输出,训练是输出时是loss,应用时是prob。
- deploy.prototxt文件代码
- name: "CIFAR10_quick"
- layer { #该层去掉
- name: "cifar"
- type: "Data"
- top: "data"
- top: "label"
- include {
- phase: TRAIN
- }
- transform_param {
- mean_file: "examples/cifar10/mean.binaryproto"
- }
- data_param {
- source: "examples/cifar10/cifar10_train_lmdb"
- batch_size: 100
- backend: LMDB
- }
- }
- layer { #该层去掉
- name: "cifar"
- type: "Data"
- top: "data"
- top: "label"
- include {
- phase: TEST
- }
- transform_param {
- mean_file: "examples/cifar10/mean.binaryproto"
- }
- data_param {
- source: "examples/cifar10/cifar10_test_lmdb"
- batch_size: 100
- backend: LMDB
- }
- }
- layer { #将下方的weight_filler、bias_filler全部删除
- name: "conv1"
- type: "Convolution"
- bottom: "data"
- top: "conv1"
- param {
- lr_mult: 1
- }
- param {
- lr_mult: 2
- }
- convolution_param {
- num_output: 32
- pad: 2
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "gaussian"
- std: 0.0001
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layer {
- name: "pool1"
- type: "Pooling"
- bottom: "conv1"
- top: "pool1"
- pooling_param {
- pool: MAX
- kernel_size: 3
- stride: 2
- }
- }
- layer {
- name: "relu1"
- type: "ReLU"
- bottom: "pool1"
- top: "pool1"
- }
- layer { #weight_filler、bias_filler删除
- name: "conv2"
- type: "Convolution"
- bottom: "pool1"
- top: "conv2"
- param {
- lr_mult: 1
- }
- param {
- lr_mult: 2
- }
- convolution_param {
- num_output: 32
- pad: 2
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "gaussian"
- std: 0.01
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layer {
- name: "relu2"
- type: "ReLU"
- bottom: "conv2"
- top: "conv2"
- }
- layer {
- name: "pool2"
- type: "Pooling"
- bottom: "conv2"
- top: "pool2"
- pooling_param {
- pool: AVE
- kernel_size: 3
- stride: 2
- }
- }
- layer { #weight_filler、bias_filler删除
- name: "conv3"
- type: "Convolution"
- bottom: "pool2"
- top: "conv3"
- param {
- lr_mult: 1
- }
- param {
- lr_mult: 2
- }
- convolution_param {
- num_output: 64
- pad: 2
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "gaussian"
- std: 0.01
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layer {
- name: "relu3"
- type: "ReLU"
- bottom: "conv3"
- top: "conv3"
- }
- layer {
- name: "pool3"
- type: "Pooling"
- bottom: "conv3"
- top: "pool3"
- pooling_param {
- pool: AVE
- kernel_size: 3
- stride: 2
- }
- }
- layer { #weight_filler、bias_filler删除
- name: "ip1"
- type: "InnerProduct"
- bottom: "pool3"
- top: "ip1"
- param {
- lr_mult: 1
- }
- param {
- lr_mult: 2
- }
- inner_product_param {
- num_output: 64
- weight_filler {
- type: "gaussian"
- std: 0.1
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layer { # weight_filler、bias_filler删除
- name: "ip2"
- type: "InnerProduct"
- bottom: "ip1"
- top: "ip2"
- param {
- lr_mult: 1
- }
- param {
- lr_mult: 2
- }
- inner_product_param {
- num_output: 10
- weight_filler {
- type: "gaussian"
- std: 0.1
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layer { #将该层删除
- name: "accuracy"
- type: "Accuracy"
- bottom: "ip2"
- bottom: "label"
- top: "accuracy"
- include {
- phase: TEST
- }
- }
- layer { #修改
- name: "loss" #---loss 修改为 prob
- type: "SoftmaxWithLoss" # SoftmaxWithLoss 修改为 softmax
- bottom: "ip2"
- bottom: "label" #去掉
- top: "loss"
- }
Caffe部署中的几个train-test-solver-prototxt-deploy等说明三相关推荐
- Caffe部署中的几个train-test-solver-prototxt-deploy等说明二
Caffe部署中的几个train-test-solver-prototxt-deploy等说明<二> 发表于2016/9/15 20:39:52 1049人阅读 分类: 神经网络与深度学 ...
- Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一)
Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一) 2016-10-13 09:07 99人阅读 评论(0) 收藏 举报 分类: caffe(18 ...
- Caffe中对cifar10执行train操作
参考Caffe source中examples/cifar10目录下内容. cifar10是一个用于普通物体识别的数据集,cifar10被分为10类,分别为airplane.automobile.bi ...
- Caffe中对MNIST执行train操作执行流程解析
之前在 http://blog.csdn.net/fengbingchun/article/details/49849225 中简单介绍过使用Caffe train MNIST的文章,当时只是仿照ca ...
- 用MATLAB训练caffe,[转载]windows caffe部署训练+python调用全部流程
原版caffe代码项目编译在windows下非常麻烦,还好微软集成了所有三方包之后放出了一个windows版本的,省了不少时间. 项目下载地址: https://github.com/Microsof ...
- caffe模型文件解析_「机器学习」截取caffe模型中的某层
通常情况下,训练好的caffe模型包含两个文件: prototxt:网络结构描述文件,存储了整个网络的图结构: caffemodel:权重文件,存储了模型权重的相关参数和具体信息 对于某些大型的网络, ...
- caffe ssd中输入图片大小对于内存使用和运行时间的影响
caffe ssd中输入图片大小对于内存使用和运行时间的影响 一.内存使用 环境为caffe下以imagenet为样本集训练resnset网络. 在初始化生成lmdb的create_ima ...
- 保障K8s部署中的安全性
开发人员需要了解如何在容器化应用程序中嵌入控件,以及如何启用运行时保护机制以阻止黑客访问容器化系统. Kubernetes是当前流行和常用的容器编排工具之一.Kubernetes工作负载就像简单的ng ...
- xcode 中无法进行虚拟机调试_在软件部署中使用 strace 进行调试
我最喜欢的用来解决"为什么这个软件无法在这台机器上运行?"这类问题的工具就是 strace. -- Simon Arneaud(作者) 我的大部分工作都涉及到部署软件系统,这意味着 ...
最新文章
- Nature灵魂拷问:微生物组数据一大堆,如何能改变人类健康?
- MVC模式与三层架构的区别
- java我的世界1.7.2怎么下载模组_我的世界1.7.2
- 深入理解spark两种调度模式:FIFO,FAIR模式
- 在 Eclipse Galileo 中更快地编写 Java 代码使用新的 toString() 生成器
- LeetCode 1653. 使字符串平衡的最少删除次数(DP)
- php汽车之家数据api,基于聚合数据的全国违章直连查询接口示例-PHP版
- CSS Transform让百分比宽高布局元素水平垂直居中
- 孟小峰:大数据管理与数据思维
- linux parrot 中文_parrot linux vi/vim命令
- Spring+SpringMVC+MyBatis深入学习及搭建(二)——MyBatis原始Dao开发和mapper代理开发(转发同上)...
- 3.nginx 的基本配置与优化
- 音视频的采集、编码、封包成 mp4 输出
- svm多分类python代码_SVM算法的理解及其Python实现多分类和二分类
- php有没有ispostback,php用什么表示IsPostBack?
- 新版FMEA软件结构树图 免费申请试用(FMEAHunter)
- 可微分神经计算机DNC
- 关于\x开头的字符串编码转换中文解决方法
- windows10系统还原
- 乐学成语(HappyIdiom)