CAFFE中训练与使用阶段网络设计的不同_1

 

神经网络中,我们通过最小化神经网络来训练网络,所以在训练时最后一层是损失函数层(LOSS),

在测试时我们通过准确率来评价该网络的优劣,因此最后一层是准确率层(ACCURACY)。

但是当我们真正要使用训练好的数据时,我们需要的是网络给我们输入结果,对于分类问题,我们需要获得分类结果,如下右图最后一层我们得到

的是概率,我们不需要训练及测试阶段的LOSS,ACCURACY层了。

下图是能过$CAFFE_ROOT/python/draw_net.py绘制$CAFFE_ROOT/models/caffe_reference_caffnet/train_val.prototxt   , $CAFFE_ROOT/models/caffe_reference_caffnet/deploy.prototxt,分别代表训练时与最后使用时的网络结构。

 

我们一般将train与test放在同一个.prototxt中,需要在data层输入数据的source,

而在使用时.prototxt只需要定义输入图片的大小通道数据参数即可,如下图所示,分别是

$CAFFE_ROOT/models/caffe_reference_caffnet/train_val.prototxt   , $CAFFE_ROOT/models/caffe_reference_caffnet/deploy.prototxt的data层

训练时, solver.prototxt中使用的是rain_val.prototxt

./build/tools/caffe/train -solver ./models/bvlc_reference_caffenet/solver.prototxt

 使用上面训练的网络提取特征,使用的网络模型是deploy.prototxt

./build/tools/extract_features.bin models/bvlc_refrence_caffenet.caffemodel models/bvlc_refrence_caffenet/deploy.prototxt

 

 

posted @ 2015-03-26 22:27  dupuleng  阅读(5627)  评论(1编辑  收藏  举报