pycaffe配置

来源:互联网 发布:基本数据分析方法 编辑:程序博客网 时间:2024/05/20 21:23

1、pycaffe介绍:

  • 参考链接:Interfaces

  • Caffe提供了python的接口(pycaffe),详见caffe/python文件夹。在python代码中import caffe,可以load models(导入模型),forward and backward(前向、反向迭代), handle IO(数据输入输出),visualize networks(net可视化),instrument model solving(自定义优化方法)。所有的模型数据、计算参数都是可供读写的。

    • caffe.Net是主要接口,负责导入数据、校验数据、计算模型的。
    • caffe.Classifier用于图像分类。
    • caffe.Detector用于图像检测。
    • caffe.SGDSolver是solver接口。
    • caffe.io处理输入输出,数据预处理。
    • caffe.draw可视化net的结构。
    • Caffe blobs以numpy ndarrays的形式表示,更加方便、高效。

2、配置pycaffe:

  • 详见Ubuntu14.04 安装Caffe(仅CPU)第10点。

    • 安装依赖库:

      $ sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython$ sudo apt-get install protobuf-c-compiler protobuf-compiler
      • 1
      • 2
    • 编译:

      $ cd ~/caffe$ make pycaffe
      • 1
      • 2
    • 添加~/caffe/python到$PYTHONPATH:

      $ sudo gedit /etc/profile# 添加: export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH$ source /etc/profile # 使之生效
      • 1
      • 2
      • 3
      • 4
      • 5
    • 测试是否可以引用:

      $ pythonPython 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import caffe>>> 
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6