caffe訓練過程中多test文件

    多test,what?通常我們在使用caffe訓練模型的時候會設定一個測試間隔(test_interval),也就是每test_interval次迭代就跑一次驗證集,觀察一下loss的變化情況。最近在訓練一個睜閉眼檢測的小模型,爲了應付各種頭部姿態,例如:擡頭、低頭等,我建立了若干個分類驗證集,在訓練過程中期望能獨立的test這些分類驗證集,得到在各分類驗證集上的loss,而不是一個整體的loss。我以擡頭睜眼(test-up-open)和低頭睜眼(test-down-open)爲例來說明一下。概括起來就兩步:(1).配置solver.prototxt;(2).配置train.prototxt。

1. solver.prototxt

net: "train.prototxt"

test_state: { stage: "test-up-open" } #擡頭睜眼
test_iter: 10 #要根據驗證集中圖片數量以及test的batch size計算

test_state: { stage: "test-down-open" } #低頭睜眼
test_iter: 20 #要根據驗證集中圖片數量以及test的batch size計算

test_interval: 500

base_lr: 0.0001
momentum: 0.9
weight_decay: 0.0005

display: 100
max_iter: 600000

type: "Adam"
lr_policy: "inv"
gamma: 0.00004
power: 0.75
solver_mode: GPU


snapshot: 500
snapshot_prefix: "snapshot"
test_compute_loss: true

2. train.prototxt

name: "eye-cls-train"
layer {
  type: "HDF5Data"
  top: "data"
  top: "label"
  hdf5_data_param {
    source: "train_h5_list.txt"
    batch_size: 128
  }
  include: { phase: TRAIN }
}
layer {
  type: "HDF5Data"
  top: "data"
  top: "label"
  hdf5_data_param {
    source: "up/open/val_h5_list.txt" #分類對應hdf5 list文件
    batch_size: 128
  }
  include: {
    phase: TEST
    stage: "test-up-open" #與solver.prototxt中定義的stage相呼應
  }
}
layer {
  type: "HDF5Data"
  top: "data"
  top: "label"
  hdf5_data_param {
    source: "down/open/val_h5_list.txt" #分類對應hdf5 list文件
    batch_size: 128
  }
  include: {
    phase: TEST
    stage: "test-down-open" #與solver.prototxt中定義的stage相呼應
  }
}
......

ok,就這麼簡單!

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