in caffe prototxt file. what does the TRAIN and TEST phase do?

社会主义新天地 提交于 2019-12-10 17:55:23

问题


I'm new to caffe. thank you guys!

in https://github.com/BVLC/caffe/blob/master/src/caffe/proto/caffe.proto

I saw 1 uncommented enum variable phase. it has 2 option TRAIN and TEST.

enum Phase {
   TRAIN = 0;
   TEST = 1;
}

how did they work? I saw a model recently has this 2 phase too. the .prototxt file looks like:

name: "CIFAR10_full"
layer {
  name: "cifar"
  type: "Data"
  top: "data"
  top: "label"
  data_param {
    source: "CIFAR-10/cifar10_train_lmdb"
    backend: LMDB
    batch_size: 200
  }
  transform_param {
    mirror: true
  }
  include: { phase: TRAIN }
}
layer {
  name: "cifar"
  type: "Data"
  top: "data"
  top: "label"
  data_param {
    source: "CIFAR-10/cifar10_test_lmdb"
    backend: LMDB
    batch_size: 100
  }
  transform_param {
    mirror: false
  }
  include: { phase: TEST }
}

can I switch from TRAIN phase to TEST phase? where is the switch?


回答1:


during training (i.e., execution of $CAFFE_ROOT/tools/caffe train [...]) caffe can alternate between training phases, and testing phases: that is, during training phase parameters are changed, while in the test phase, the parameters are fixed and the model only runs feed forward examples to estimate the current performance of the model.
It is quite natural to use two different data sets for training and testing, and this is why you use the different phase values.

You can read more about the train/test iterations here.




回答2:


TRAIN specifies a layer for the model used during training.

TEST specifies a layer for the model used during testing.

Thus, you can define 2 models in the single prototxt file: one model for training and one model for testing.

Info on this can be found in the Model Definition section of the web page http://caffe.berkeleyvision.org/gathered/examples/imagenet.html



来源:https://stackoverflow.com/questions/37659976/in-caffe-prototxt-file-what-does-the-train-and-test-phase-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!