caffe linux下面的調試mnist遇到的問題


搭建環境參考

http://blog.csdn.net/ubunfans/article/details/47724341

這個教程基本是正確的。

補充一點就是

make all -j4  

之后,在build/bin/下面會生成很多*.bin文件,就證明編譯成功。

 

下面是運行mnist,執行到create_mnist.sh這一步的時候遇見了一個問題

./create_mnist.sh: 17: ./create_mnist.sh: build/examples/mnist/convert_mnist_data.bin: not found

這個要變換目錄才可以

注意:新版caffe都需要從根目錄上執行,不然可能會遇到這個錯誤

ubuntu@ubuntu-PC:~/work/caffe-master$ cp examples/mnist/create_mnist.sh ./
ubuntu@ubuntu-PC:~/work/caffe-master$ ./create_mnist.sh 

看看官方給的教程

cd $CAFFE_ROOT
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh

直接根據官方的教程來配置算了

http://caffe.berkeleyvision.org/gathered/examples/mnist.html

結尾也就是官方自己的數據測試完,得到一個99%的准確度,然后就完了(很多博客也是這樣就結束了),就大功告成!#$%%%%*& what the fu*k!!!!

不用自己那點數據來測一下嗎??

那好吧,我來續命....

可以用python,也可以用c++自己調用classification.bin

如果不動用法,直接

./build/examples/cpp_classification/classification.bin

會提示你使用方法的

python:

    import os    
    import sys    
    import numpy as np    
    import matplotlib.pyplot as plt    
    caffe_root = '/home/vr/Documents/Caffe/setup/caffe-master/'    
    sys.path.insert(0, caffe_root + 'python')    
    import caffe    
    MODEL_FILE = '/home/vr/Documents/Caffe/setup/caffe-master/examples/mnist/lenet.prototxt'    
    PRETRAINED = '/home/vr/Documents/Caffe/setup/caffe-master/examples/mnist/lenet_iter_10000.caffemodel'    
    IMAGE_FILE = '/home/vr/Documents/Caffe/setup/caffe-master/examples/mnist/test/0012.jpg'    
      
    input_image=caffe.io.load_image(IMAGE_FILE,color=False)  
    #print input_image  
    net = caffe.Classifier(MODEL_FILE, PRETRAINED)   
      
    prediction=net.predict([input_image])   
    caffe.set_mode_cpu()  
    print 'predicted class:', prediction[0].argmax()   

.sh腳本調用

./build/examples/cpp_classification/classification.bin \
examples/mnist/classificat_net.prototxt \
examples/mnist/lenet_iter_10000.caffemodel \
examples/mnist/mean.binaryproto examples/mnist/label.txt \
examples/mnist/0.png

什么???參數太多?

可以,直接改classification.cpp文件

重新編譯classification.bin

 

遇到新問題了,執行classification.bin的時候找不到庫!so庫!

 

./build/tools/caffe: error while loading shared libraries: libcaffe.so.1.0.0-rc5: cannot open shared object file: No such file or directory

 

參考https://github.com/BVLC/caffe/issues/1463
里面有一個解決方法說的是要把庫(或者庫的軟鏈接)拷到 /usr/lib/x86_64-linux-gnu/目錄下

 

sudo cp distribute/bin/libcaffe.so.1.0.0-rc5 /usr/lib/x86_64-linux-gnu/

 

果然運行正常了。

(未完,待續)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM