theanorc

[global]
device = cpu
floatX = float32
cxx = icpc
mode = FAST_RUN
openmp = True
openmp_elemwise_minsize = 10
allow_gc = False
#profile = True
[gcc]
cxxflags = -qopenmp -march=native -O3  -qopt-report=3 -fno-alias -qopt-prefetch=2 -fp-trap=none
[blas]
# using Intel MKL library
ldflags = -lmkl_rt
# using Intel MKLML library
# ldflags = -lmklml_intel
[mkl.nn]
#enabled = False

copy from linuxidc.

一、caffe 创建python 层

因为caffe底层是用c++编写的,所以我们有的时候想要添加某一个最新文献出来的新算法,正常的方法是直接编写c++网络层,然而这个有个前提条件是必须对caffe的底层非常熟悉,c++的编写达到一定的境界,才可灵活应用caffe,搞深度学习,走这条路对于菜鸟来说无疑很有难度。

好在caffe为我们提供了一个可以用python编写新的网络层的方法,直接用python语言编写新的网络层,然后在caffe的网络配置文件,稍作修改,就可以轻松容易创建新的网络层。其具体环境配置搭建过程如下:

1、编译caffe的时候,不能直接使用make pycaffe,而是应该使用:

WITH_PYTHON_LAYER=1 make && make pycaffe

2、编写相关的网络层文件python源码filename.py,同时需要在filename.py 编写的时候,import caffe的时候,需要指向caffe所在的路径目录

3、把python源码文件filename.py拷贝到caffe/python目录下:

caffe/python/filename.py

4、添加路径变量:

sudo vim ~/.bashrc
在最后输入

export PYTHONPATH=/home/hjimce/tools/caffenewversion/python:$PYTHONPATH
重启电脑.

5、调用的时候,引用层:

layer {
  type: 'Python'
  name: 'loss'
  top: 'loss'
  bottom: 'f2'
  bottom: 'label'
  python_param {
    # the module name -- usually the filename -- that needs to be in $PYTHONPATH
    module: 'filename'
    # the layer name -- the class name in the module
    layer: 'NormlizedMSE'
  }
  # set loss weight so Caffe knows this is a loss layer.
  # since PythonLayer inherits directly from Layer, this isn't automatically
  # known to Caffe
  loss_weight: 1
}

二、caffe关闭日志输出消息

可能对于算法实验阶段来说,我们需要caffe运行网络的时候,打印网络的相关参数消息。然而对于已经走向工程之路的caffe模型来说,我们有可能需要屏蔽那些没用的输出消息,因此这个时候就需要用到caffe的消息屏蔽。

1、在程序最开始运行地方,加入如下代码:

::google::InitGoogleLogging("hjimce"); //初始化
FLAGS_stderrthreshold = ::google::ERROR; //只打印ERROR级别信息

2、在程序结束的时候加入代码:

google::ShutdownGoogleLogging();

Ubuntu 16.04下Matlab2014a+Anaconda2+OpenCV3.1+Caffe安装 http://www.linuxidc.com/Linux/2016-07/132860.htm

Ubuntu 16.04系统下CUDA7.5配置Caffe教程 http://www.linuxidc.com/Linux/2016-07/132859.htm

Caffe在Ubuntu 14.04 64bit 下的安装 http://www.linuxidc.com/Linux/2015-07/120449.htm

深度学习框架Caffe在Ubuntu下编译安装 http://www.linuxidc.com/Linux/2016-07/133225.htm

Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明 http://www.linuxidc.com/Linux/2015-04/116444.htm

Ubuntu 16.04上安装Caffe http://www.linuxidc.com/Linux/2016-08/134585.htm

Caffe配置简明教程 ( Ubuntu 14.04 / CUDA 7.5 / cuDNN 5.1 / OpenCV 3.1 ) http://www.linuxidc.com/Linux/2016-09/135016.htm

原文地址:https://www.cnblogs.com/Viewsky/p/7552228.html