caffe中train_val.prototxt文件和deploy.prototxt文件区别和转换--caffe学习(14)
来源:互联网 发布:淘宝卖家吧 编辑:程序博客网 时间:2024/06/05 06:27
先放出二者的完整例子文件,然后分析:
train_val.prototxt文件如下:
name: "CaffeNet"layer {name: "data"type: "Data"top: "data"top: "label"include {phase: TRAIN}transform_param {mirror: truecrop_size: 227mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"}# mean pixel / channel-wise mean instead of mean image# transform_param {# crop_size: 227# mean_value: 104# mean_value: 117# mean_value: 123# mirror: true# }data_param {source: "examples/imagenet/ilsvrc12_train_lmdb"batch_size: 256backend: LMDB}}layer {name: "data"type: "Data"top: "data"top: "label"include {phase: TEST}transform_param {mirror: falsecrop_size: 227mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"}# mean pixel / channel-wise mean instead of mean image# transform_param {# crop_size: 227# mean_value: 104# mean_value: 117# mean_value: 123# mirror: false# }data_param {source: "examples/imagenet/ilsvrc12_val_lmdb"batch_size: 50backend: LMDB}}layer {name: "conv1"type: "Convolution"bottom: "data"top: "conv1"param {lr_mult: 1decay_mult: 1}param {lr_mult: 2decay_mult: 0}convolution_param {num_output: 96kernel_size: 11stride: 4weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 0}}}param {lr_mult: 2decay_mult: 0}convolution_param {num_output: 256pad: 2kernel_size: 5group: 2weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 1}m {lr_mult: 2decay_mult: 0}convolution_param {num_output: 384pad: 1kernel_size: 3weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 0}}}layer {name: "relu3"type: "ReLU"bottom: "conv3"top: "conv3"}layer {name: "conv4"type: "Convolution"bottom: "conv3"top: "conv4"param {lr_mult: 1decay_mult: 1}param {lr_mult: 2decay_mult: 0}convolution_param {num_output: 384pad: 1kernel_size: 3group: 2weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 1}}}layer {name: "relu4"type: "ReLU"bottom: "conv4"top: "conv4"}layer {name: "conv5"type: "Convolution"bottom: "conv4"top: "conv5"param {lr_mult: 1decay_mult: 1}param {lr_mult: 2decay_mult: 0}convolution_param {num_output: 256pad: 1kernel_size: 3group: 2weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 1}}layer {name: "fc6"type: "InnerProduct"bottom: "pool5"top: "fc6"param {lr_mult: 1decay_mult: 1}param {lr_mult: 2decay_mult: 0}inner_product_param {num_output: 4096weight_filler {type: "gaussian"std: 0.005}bias_filler {type: "constant"value: 1}}}layer {name: "relu6"type: "ReLU"bottom: "fc6"top: "fc6"}layer {name: "drop6"type: "Dropout"bottom: "fc6"top: "fc6"dropout_param {dropout_ratio: 0.5}layer {name: "relu7"type: "ReLU"bottom: "fc7"top: "fc7"}}layer {name: "fc8"type: "InnerProduct"bottom: "fc7"top: "fc8"param {lr_mult: 1decay_mult: 1}param {lr_mult: 2decay_mult: 0}inner_product_param {num_output: 1000weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 0}}}layer {name: "accuracy"type: "Accuracy"bottom: "fc8"bottom: "label"top: "accuracy"include {phase: TEST}}layer {name: "loss"type: "SoftmaxWithLoss"bottom: "fc8"bottom: "label"top: "loss"}
修改后的deploy.prototxt文件:
name: "CaffeNet"layer { name: "data" type: "Input" top: "data" input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }}layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" convolution_param { num_output: 96 kernel_size: 11 stride: 4 }。。。。。。。。。。。。。。layer { name: "fc8" type: "InnerProduct" bottom: "fc7" top: "fc8" inner_product_param { num_output: 1000 }}layer { name: "prob" type: "Softmax" bottom: "fc8" top: "prob"}
变化的有几个地方:
1:输入数据层data层:将原来的train和test输入数据参数完全删除,
删除的部分:
layer {name: "data"type: "Data"top: "data"top: "label"include {phase: TRAIN}transform_param {mirror: truecrop_size: 227mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"}# mean pixel / channel-wise mean instead of mean image# transform_param {# crop_size: 227# mean_value: 104# mean_value: 117# mean_value: 123# mirror: true# }data_param {source: "examples/imagenet/ilsvrc12_train_lmdb"batch_size: 256backend: LMDB}}layer {name: "data"type: "Data"top: "data"top: "label"include {phase: TEST}transform_param {mirror: falsecrop_size: 227mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"}# mean pixel / channel-wise mean instead of mean image# transform_param {# crop_size: 227# mean_value: 104# mean_value: 117# mean_value: 123# mirror: false# }data_param {source: "examples/imagenet/ilsvrc12_val_lmdb"batch_size: 50backend: LMDB}}
用这样的代替
layer { name: "data" type: "Input" top: "data" input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }}
shape: { dim: 10 dim: 3 dim: 227 dim: 227 }中第一个dim代表卷积核个数10个,第二个dim代表channel个数3个(对于图片是RGB三通道),第三第四个分别是width和height图片的。
2:卷积层中对应参数:
**weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 1}**
完全删除,可以用关键字weight_filler和bias_filler来删除,他们是指定学习的参数的,deploy时用model中的参数,而不用自己更新,故删去。
3:最后的
layer {name: "accuracy"type: "Accuracy"bottom: "fc8"bottom: "label"top: "accuracy"include {phase: TEST}
完全删除,不需要test
4:原来的最后一层loss层改为pro层
layer {name: "loss"type: "SoftmaxWithLoss"bottom: "fc8"bottom: "label"top: "loss"}
A:将其中的SoftmaxWithLoss替换为Softmax
B:删除其中的bottom:”label”行,因为测试时需要预测label而不是给你一个已知label。
C:同时将最后一层loss层改为pro层
因此改完之后最后一层就是这样的:
layer { name: "prob" type: "Softmax" bottom: "fc8" top: "prob"}
这里的name: “prob”就是你在用python预测时读取的layer的name,一定要对应上
1 0
- caffe中train_val.prototxt文件和deploy.prototxt文件区别和转换--caffe学习(14)
- caffe中train_val.prototxt和deploy.prototxt文件的区别
- caffe中train_val.prototxt和deploy.prototxt文件的区别
- caffe中train_val.prototxt和deploy.prototxt转换 ResNet_18_deploy.prototxt
- 浅谈caffe中train_val.prototxt和deploy.prototxt文件的区别
- 浅谈caffe中train_val.prototxt和deploy.prototxt文件的区别
- 浅谈caffe中train_val.prototxt和deploy.prototxt文件的区别
- 浅谈caffe中train_val.prototxt和deploy.prototxt文件的区别
- 浅谈caffe中train_val.prototxt和deploy.prototxt文件的区别
- train_val.prototxt和deploy.prototxt文件解读
- caffe中mnist中 lenet_train_test.prototxt和lenet.prototxt(deploy文件)区别
- caffe中train_val.prototxt与deploy.prototxt的区别
- train_val.prototxt和deploy.prototxt
- 区分caffe中train.prototxt,solver.prototxt,deploy.prototxt等文件
- caffe将用训练好的caffemodel和train_val.prototxt文件分类新的一张图片-上篇--caffe学习(6)
- caffe将用训练好的caffemodel和train_val.prototxt文件分类新的一张图片-下篇--caffe学习(7)
- 深度学习caffe平台--train_val.prototxt文件中数据层及参数详解
- 深度学习caffe平台--train_val.prototxt文件中视觉层(Vision Layers)层及参数详解
- /*2017年1月10日*/日志
- 基于Qt Assistant制作软件帮助文档
- javaee JSTL
- weblogic12 在linux 上的静默安装
- 【BZOJ 1954】Pku3764 The xor-longest Path trie+贪心
- caffe中train_val.prototxt文件和deploy.prototxt文件区别和转换--caffe学习(14)
- PE 131 Prime cube partnership (数论)
- cubietruck如何利用hostpad建立局域网
- studio 中我常用的快捷键
- (三十五)信号——SIGCHLD信号处理
- matlab的Regionprops详解
- 使用maven的tomcat插件实现webapp的自动部署
- 框架 day85 涛涛商城项目-nginx反向代理,负载均衡,部署solr集群
- 继承中的构造和析构