Caffe-如何修改爲deploy.prototxt用於測試

(1)將原網絡文件去掉(以下部分)

layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    crop_size: 227
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  data_param {
    source: "D:/Master/master_graduate/dataset/test/squeezt-test1/train_LEVELDB"
    batch_size: 32
    backend: LEVELDB
  }
}
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    crop_size: 227
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  data_param {
    source: "D:/Master/master_graduate/dataset/test/squeezt-test1/test_LEVELDB"
    batch_size: 25 
    backend: LEVELDB
  }
}

(2)將最後的accuracy和loss層去掉,如下部分

layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "pool10"
  bottom: "label"
  top: "loss"
  include {
    phase: TRAIN
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "pool10"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "accuracy_top5"
  type: "Accuracy"
  bottom: "pool10"
  bottom: "label"
  top: "accuracy_top5"
  include {
    phase: TEST
  }
  accuracy_param {
    top_k: 5
  }
}

(3)在最前面加如下部分:

name:"SqueezeNet"
input:"data"
input_shape{
  dim:1
  dim:1
  dim:28
  dim:28
}

(4)在最下面加如下部分:

layer {
  name: "prob"
  type: "SoftmaxWithLoss"
  bottom: "pool10"
  top: "prob"
  }

其中,bottom是上一層的輸出,top爲“prob”。

OK,至此修改完畢。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章