caffe pyhton net.set_phase_test() seems do not work

1,599 views
Skip to first unread message

Guoliang Kang

unread,
Feb 11, 2015, 7:15:16 AM2/11/15
to caffe...@googlegroups.com

It seems that in the python version of caffe, net.set_phase_test() does not work. In my practice, no matter what phase you set( train or test), it always filter the layers which are set to exist only in the test process. That is, it always uses the trained model other than the test model which are defined in the model prototxt. I do not know why, is it a bug or I use it mistakely?

For example,

net = caffe.Classifier(caffe_root + 'models/bvlc_reference_caffenet/deploy.prototxt',
                       caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel')

If I set the last layer to exist only in the test phase, like this:
layers {
  name: "prob"
  type: SOFTMAX
  bottom: "fc8"
  top: "prob"
  include: {phase: TEST}
}

And then this layer will be filtered, although in the init of Classifier "self.set_phase_test()" is excuted! 

Furthermore, in the http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/filter_visualization.ipynb
caffe.set_phase_test()
caffe.set_mode_cpu()
will cause an error:" AttributeError: 'module' object has no attribute 'set_phase_train' ". Is it because of any change of caffe version?



Shuang Ao

unread,
Mar 26, 2015, 10:03:46 AM3/26/15
to caffe...@googlegroups.com
For the current python wrapper, you don't have to set the test phrase. Just delete it and it will work for testing.

在 2015年2月11日星期三 UTC-5上午7:15:16,Guoliang Kang写道:
Reply all
Reply to author
Forward
0 new messages