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

  

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM