Caffe GoogleNet classification.cpp gives random outputs

谁说我不能喝 提交于 2019-12-25 07:14:04

问题


I used Caffe GoogleNet model to train my own data (10k images, 2 classes). I stop it at 400000th iteration with an accuracy of ~80%.

If I run the below command:

./build/examples/cpp_classification/classification.bin
  models/bvlc_googlenet/deploy.prototxt  
  models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel 
  data/ilsvrc12/imagenet_mean.binaryproto
  data/ilsvrc12/synset_words.txt
  1.png

it gives me a different -- apparently random -- result each time (i.e. if I run it n times, then I get n different results). Why? Does my training fail? Does it still use the old data from the reference model?


回答1:


I don't think it is a problem with the training. Even if the training data wasn't, it should give the same (possibly wrong) output every time. If you are getting random results, it indicates that the weights are not being loaded properly.

When you load a .caffemodel against a .prototxt, caffe will load the weights of all the layers in the prototxt whose names match with the ones in the caffemodel. For the other layers, it will do a random initialisation (gaussian xavier, etc according to the specification in the prototxt).

So the best thing for you to do now is to check if the model was trained using the same prototxt you are using now.

I see that you are using GoogleNet prototxt and reference_caffenet caffemodel. Is this intentional?




回答2:


When you want to deploy the fine-tuned model, you should check two main things:

  1. Inputs:

    • Input image uses a BGR channel instead of RGB (e.g. opencv)
    • Mean file: Is same as mean file when training?
  2. Prototxt:

    • When fintuning the model, you will change some layers' name in the original prototxt, and you should check whether the same layer name used?

And there are some Fine-tune tricks and CS231n_transfer_learning which are very useful for finetuning.



来源:https://stackoverflow.com/questions/38312250/caffe-googlenet-classification-cpp-gives-random-outputs

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