3

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?

Shai
  • 111,146
  • 38
  • 238
  • 371
Long
  • 366
  • 4
  • 13

2 Answers2

4

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.

Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371
  • 2
    Thank you Shai! you are really my Savior. You've answered a dozen of my questions. – Long Jun 07 '16 at 03:45
0

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

user3731622
  • 4,844
  • 8
  • 45
  • 84