caffe生成deploy.prototxt文件

参考:

http://blog.csdn.net/cham_3/article/details/52682479

 

以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文件  

  

  

转载于:https://www.cnblogs.com/k7k8k91/p/7806232.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值