Caffe部署中的几个train-test-solver-prototxt-deploy等说明<三>

2016-10-13 14:16 147人阅读 评论(0) 收藏 举报
 分类:
caffe(18) 

转载地址: 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

[plain] view plaincopy
  1. ./build/tools/caffe/train -solver ./models/bvlc_reference_caffenet/solver.prototxt

使用上面训练的网络提取特征,使用的网络模型是deploy.prototxt

[plain] view plaincopy
  1. ./build/tools/extract_features.bin models/bvlc_refrence_caffenet.caffemodel models/bvlc_refrence_caffenet/deploy.prototxt

2:

*_train_test.prototxt文件:这是训练与测试网络配置文件

*_deploy.prototxt文件:这是模型构造文件
deploy.prototxt文件书写:
注意在输出层的类型发生了变化一个是SoftmaxWithLoss,另一个是Softmax。另外为了方便区分训练与应用输出,训练是输出时是loss,应用时是prob。

[plain] view plaincopy
  1. deploy.prototxt文件代码
  2. name: "CIFAR10_quick"
  3. layer {               #该层去掉
  4. name: "cifar"
  5. type: "Data"
  6. top: "data"
  7. top: "label"
  8. include {
  9. phase: TRAIN
  10. }
  11. transform_param {
  12. mean_file: "examples/cifar10/mean.binaryproto"
  13. }
  14. data_param {
  15. source: "examples/cifar10/cifar10_train_lmdb"
  16. batch_size: 100
  17. backend: LMDB
  18. }
  19. }
  20. layer {             #该层去掉
  21. name: "cifar"
  22. type: "Data"
  23. top: "data"
  24. top: "label"
  25. include {
  26. phase: TEST
  27. }
  28. transform_param {
  29. mean_file: "examples/cifar10/mean.binaryproto"
  30. }
  31. data_param {
  32. source: "examples/cifar10/cifar10_test_lmdb"
  33. batch_size: 100
  34. backend: LMDB
  35. }
  36. }
  37. layer {                        #将下方的weight_filler、bias_filler全部删除
  38. name: "conv1"
  39. type: "Convolution"
  40. bottom: "data"
  41. top: "conv1"
  42. param {
  43. lr_mult: 1
  44. }
  45. param {
  46. lr_mult: 2
  47. }
  48. convolution_param {
  49. num_output: 32
  50. pad: 2
  51. kernel_size: 5
  52. stride: 1
  53. weight_filler {
  54. type: "gaussian"
  55. std: 0.0001
  56. }
  57. bias_filler {
  58. type: "constant"
  59. }
  60. }
  61. }
  62. layer {
  63. name: "pool1"
  64. type: "Pooling"
  65. bottom: "conv1"
  66. top: "pool1"
  67. pooling_param {
  68. pool: MAX
  69. kernel_size: 3
  70. stride: 2
  71. }
  72. }
  73. layer {
  74. name: "relu1"
  75. type: "ReLU"
  76. bottom: "pool1"
  77. top: "pool1"
  78. }
  79. layer {                         #weight_filler、bias_filler删除
  80. name: "conv2"
  81. type: "Convolution"
  82. bottom: "pool1"
  83. top: "conv2"
  84. param {
  85. lr_mult: 1
  86. }
  87. param {
  88. lr_mult: 2
  89. }
  90. convolution_param {
  91. num_output: 32
  92. pad: 2
  93. kernel_size: 5
  94. stride: 1
  95. weight_filler {
  96. type: "gaussian"
  97. std: 0.01
  98. }
  99. bias_filler {
  100. type: "constant"
  101. }
  102. }
  103. }
  104. layer {
  105. name: "relu2"
  106. type: "ReLU"
  107. bottom: "conv2"
  108. top: "conv2"
  109. }
  110. layer {
  111. name: "pool2"
  112. type: "Pooling"
  113. bottom: "conv2"
  114. top: "pool2"
  115. pooling_param {
  116. pool: AVE
  117. kernel_size: 3
  118. stride: 2
  119. }
  120. }
  121. layer {                         #weight_filler、bias_filler删除
  122. name: "conv3"
  123. type: "Convolution"
  124. bottom: "pool2"
  125. top: "conv3"
  126. param {
  127. lr_mult: 1
  128. }
  129. param {
  130. lr_mult: 2
  131. }
  132. convolution_param {
  133. num_output: 64
  134. pad: 2
  135. kernel_size: 5
  136. stride: 1
  137. weight_filler {
  138. type: "gaussian"
  139. std: 0.01
  140. }
  141. bias_filler {
  142. type: "constant"
  143. }
  144. }
  145. }
  146. layer {
  147. name: "relu3"
  148. type: "ReLU"
  149. bottom: "conv3"
  150. top: "conv3"
  151. }
  152. layer {
  153. name: "pool3"
  154. type: "Pooling"
  155. bottom: "conv3"
  156. top: "pool3"
  157. pooling_param {
  158. pool: AVE
  159. kernel_size: 3
  160. stride: 2
  161. }
  162. }
  163. layer {                       #weight_filler、bias_filler删除
  164. name: "ip1"
  165. type: "InnerProduct"
  166. bottom: "pool3"
  167. top: "ip1"
  168. param {
  169. lr_mult: 1
  170. }
  171. param {
  172. lr_mult: 2
  173. }
  174. inner_product_param {
  175. num_output: 64
  176. weight_filler {
  177. type: "gaussian"
  178. std: 0.1
  179. }
  180. bias_filler {
  181. type: "constant"
  182. }
  183. }
  184. }
  185. layer {                              # weight_filler、bias_filler删除
  186. name: "ip2"
  187. type: "InnerProduct"
  188. bottom: "ip1"
  189. top: "ip2"
  190. param {
  191. lr_mult: 1
  192. }
  193. param {
  194. lr_mult: 2
  195. }
  196. inner_product_param {
  197. num_output: 10
  198. weight_filler {
  199. type: "gaussian"
  200. std: 0.1
  201. }
  202. bias_filler {
  203. type: "constant"
  204. }
  205. }
  206. }
  207. layer {                                  #将该层删除
  208. name: "accuracy"
  209. type: "Accuracy"
  210. bottom: "ip2"
  211. bottom: "label"
  212. top: "accuracy"
  213. include {
  214. phase: TEST
  215. }
  216. }
  217. layer {                                 #修改
  218. name: "loss"       #---loss  修改为  prob
  219. type: "SoftmaxWithLoss"             # SoftmaxWithLoss 修改为 softmax
  220. bottom: "ip2"
  221. bottom: "label"          #去掉
  222. top: "loss"
  223. }

Caffe部署中的几个train-test-solver-prototxt-deploy等说明三相关推荐

  1. Caffe部署中的几个train-test-solver-prototxt-deploy等说明二

    Caffe部署中的几个train-test-solver-prototxt-deploy等说明<二> 发表于2016/9/15 20:39:52  1049人阅读 分类: 神经网络与深度学 ...

  2. Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一)

    Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一) 2016-10-13 09:07 99人阅读 评论(0) 收藏 举报  分类: caffe(18 ...

  3. Caffe中对cifar10执行train操作

    参考Caffe source中examples/cifar10目录下内容. cifar10是一个用于普通物体识别的数据集,cifar10被分为10类,分别为airplane.automobile.bi ...

  4. Caffe中对MNIST执行train操作执行流程解析

    之前在 http://blog.csdn.net/fengbingchun/article/details/49849225 中简单介绍过使用Caffe train MNIST的文章,当时只是仿照ca ...

  5. 用MATLAB训练caffe,[转载]windows caffe部署训练+python调用全部流程

    原版caffe代码项目编译在windows下非常麻烦,还好微软集成了所有三方包之后放出了一个windows版本的,省了不少时间. 项目下载地址: https://github.com/Microsof ...

  6. caffe模型文件解析_「机器学习」截取caffe模型中的某层

    通常情况下,训练好的caffe模型包含两个文件: prototxt:网络结构描述文件,存储了整个网络的图结构: caffemodel:权重文件,存储了模型权重的相关参数和具体信息 对于某些大型的网络, ...

  7. caffe ssd中输入图片大小对于内存使用和运行时间的影响

    caffe ssd中输入图片大小对于内存使用和运行时间的影响 一.内存使用 环境为caffe下以imagenet为样本集训练resnset网络.       在初始化生成lmdb的create_ima ...

  8. 保障K8s部署中的安全性

    开发人员需要了解如何在容器化应用程序中嵌入控件,以及如何启用运行时保护机制以阻止黑客访问容器化系统. Kubernetes是当前流行和常用的容器编排工具之一.Kubernetes工作负载就像简单的ng ...

  9. xcode 中无法进行虚拟机调试_在软件部署中使用 strace 进行调试

    我最喜欢的用来解决"为什么这个软件无法在这台机器上运行?"这类问题的工具就是 strace. -- Simon Arneaud(作者) 我的大部分工作都涉及到部署软件系统,这意味着 ...

最新文章

  1. Nature灵魂拷问:微生物组数据一大堆,如何能改变人类健康?
  2. MVC模式与三层架构的区别
  3. java我的世界1.7.2怎么下载模组_我的世界1.7.2
  4. 深入理解spark两种调度模式:FIFO,FAIR模式
  5. 在 Eclipse Galileo 中更快地编写 Java 代码使用新的 toString() 生成器
  6. LeetCode 1653. 使字符串平衡的最少删除次数(DP)
  7. php汽车之家数据api,基于聚合数据的全国违章直连查询接口示例-PHP版
  8. CSS Transform让百分比宽高布局元素水平垂直居中
  9. 孟小峰:大数据管理与数据思维
  10. linux parrot 中文_parrot linux vi/vim命令
  11. Spring+SpringMVC+MyBatis深入学习及搭建(二)——MyBatis原始Dao开发和mapper代理开发(转发同上)...
  12. 3.nginx 的基本配置与优化
  13. 音视频的采集、编码、封包成 mp4 输出
  14. svm多分类python代码_SVM算法的理解及其Python实现多分类和二分类
  15. php有没有ispostback,php用什么表示IsPostBack?
  16. 新版FMEA软件结构树图 免费申请试用(FMEAHunter)
  17. 可微分神经计算机DNC
  18. 关于\x开头的字符串编码转换中文解决方法
  19. windows10系统还原
  20. 乐学成语(HappyIdiom)

热门文章

  1. java 线程包_Java 多线程——工具包
  2. 云服务器 cvm操作系统选择,云服务器cvm操作系统选择
  3. 设置代理_ie浏览器一键取消自动检测设置并设置代理
  4. Linux uart寄存器读写,Linux下读写UART串口的代码
  5. 汇编语言程序设计c,c与汇编语言程序设计
  6. opencv 边缘检测
  7. pyspark github算例 计算平均数
  8. numpy 笔记: random模块
  9. 听说你想去大厂看妹子,带你看看腾讯产品运营岗超详细面经
  10. 补贴背后的商业竞争,你真的懂吗?