caffe生成deploy.prototxt文件
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
caffe⽣成deploy.prototxt⽂件参考:
以caffe⼯程⾃带的mnist数据集,lenet⽹络为例:
将lenet_train_test.prototxt⽂件进⾏⼀些修改即可得到lenet.prototxt⽂件
头部:
去除训练⽤的输⼊数据层,
layer {
name: "mnist"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
mean_file: "mean.binaryproto"
scale: 0.00390625
}
data_param {
source: "examples/mnist/mnist_train_lmdb"
batch_size: 64
backend: LMDB
}
}
layer {
name: "mnist"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
mean_file: "mean.binaryproto"
scale: 0.00390625
}
data_param {
source: "examples/mnist/mnist_test_lmdb"
batch_size: 100
backend: LMDB
}
}
添加数据,
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 64 dim: 1 dim: 28 dim: 28 } }
}
中间的部分:
conv1-pool1-conv2-pool2-ip1-relu1-ip2中间的这些层是相同的
尾部:
lenet_train_test.prototxt去除,
layer {
name: "accuracy"
type: "Accuracy"
bottom: "ip2"
bottom: "label"
top: "accuracy"
include {
phase: TEST
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "ip2"
bottom: "label"
top: "loss"
}
添加,
layer {
name: "prob"
type: "Softmax"
bottom: "ip2"
top: "prob"
}
即可得到lenet.prototxt⽂件
以siftflow-fcn32s为例,说明:
打开trainval.prototxt⽂件,删除,
layer {
name: "data"
type: "Python"
top: "data"
top: "sem"
top: "geo"
python_param {
module: "siftflow_layers"
layer: "SIFTFlowSegDataLayer"
param_str: "{\'siftflow_dir\': \'../data/sift-flow\', \'seed\': 1337, \'split\': \'trainval\'}" }
}
添加,
layer {
name: "input"
type: "Input"
top: "data"
input_param {
# These dimensions are purely for sake of example;
# see infer.py for how to reshape the net to the given input size.
shape { dim: 1 dim: 3 dim: 256 dim: 256 }
}
}
中间的⽹络层都是相同的,
尾部,删除两个⽹络的loss层,
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "score_sem"
bottom: "sem"
top: "loss"
loss_param {
ignore_label: 255
normalize: false
}
}
layer {
name: "loss_geo"
type: "SoftmaxWithLoss"
bottom: "score_geo"
bottom: "geo"
top: "loss_geo"
loss_param {
ignore_label: 255
normalize: false
}
}
即可得到deploy.prototxt⽂件 。