zoukankan      html  css  js  c++  java
  • 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/

    果然运行正常了。

    (未完,待续)

  • 相关阅读:
    401. Binary Watch
    46. Permutations
    61. Rotate List
    142. Linked List Cycle II
    86. Partition List
    234. Palindrome Linked List
    19. Remove Nth Node From End of List
    141. Linked List Cycle
    524. Longest Word in Dictionary through Deleting
    android ListView详解
  • 原文地址:https://www.cnblogs.com/baldermurphy/p/6528077.html
Copyright © 2011-2022 走看看