Windows下关于稀疏编码建模工具箱SPAMS的配置

来源:互联网 发布:喜夜网络娴主播 编辑:程序博客网 时间:2024/06/07 14:58

SPAMS(SPArse Modeling Software)这里就不做过多地介绍啦,不懂的可以自行查找资料阅读,下面直接上干货~~

下载地址:http://spams-devel.gforge.inria.fr/index.html,我这里下载的是spams-matlab-v2.5,解压后的文件夹是这样的:


关于该工具箱各个函数的使用(每个函数都有一个测试文件供测试,在test_release文件夹中)可以参考doc文件夹下的doc_spams.pdf文件。

该工具包给出的是C++代码,所以需要编译才能最终使用。也正是因为如此,该工具箱不仅可以跨平台,而且运行速度也很快。

对于安装,可以在在HOW_TO_INSTALL.txt中有简单说明,这里稍微总结一下,就是叫你使用compile.m进行文件编译,对于不同的计算机,配置都在这个文件中调整,所以 使用matlab打开compile.m文件,前144行是用来做配置的,后面的就不要乱动了,作者是这样说的:


意思就是叫你不要乱动接下来的行。

从compile.m文件可以看到,前144行的配置主要涉及4个部分:COMPILER CONFIGURATION 编译器配置、BLAS/LAPACK CONFIGURATION 数学函数库配置、MULTITHREADING CONFIGURATION 多线程配置、PATH CONFIGURATION 路径配置。

那么我们所要做的就是根据自己的电脑修改相应的配置(其实就是设置参数,从compile.m文件中我们也可以看的出来)。我的电脑配置如下(win10 64bit、matlab R2014a、vs2013),那么我们相关配置如下:

1、COMPILER CONFIGURATION 编译器配置

%%%%%%%%%%%%% COMPILER CONFIGURATION %%%%%%%%%%%%%%%%
%编译器配置
% set up the compiler you want to use. Possible choices are
%   - 'mex' (default matlab compiler), this is the easy choice if your matlab
%           is correctly configured. Note that this choice might not compatible
%           with the option 'use_multithread=true'. 
%   - 'icc' (intel compiler), usually produces the fastest code, but the
%           compiler is not free and not installed by default.
%   - 'gcc' (gnu compiler), good choice (for Mac, use gcc >= 4.6 for
%           the multi-threaded version, otherwise set use_multithread=false).
%           For windows, you need to have cygwin installed.
%   - 'clang'
%   - 'open64' (amd compiler), optimized for opteron cpus.
%   - 'vs'  (visual studio compiler) for windows computers (10.0 or more is recommended)
%            for some unknown reason, the performance obtained with vs is poor compared to icc/gcc
compiler='mex';%这里我使用的matlab默认的编译器。我们可以使用mex -setup配置matlab默认编译器,比如我想编译现在的cpp文件,那么我配置matlab为“mex -setup C++ ”,如下图所示:


点击mex -setup C++就可以啦,其实就是执行了该命令。

注:这里其实就跟compiler='vs'一样了,只是如果配置成'vs',下面需要改vs编译器路径,使用'mex'相当于让matlab帮配置好了,后面的路径配置什么也不用管。

2、BLAS/LAPACK CONFIGURATION 数学函数库配置

 %%%%%%%%%%%% BLAS/LAPACK CONFIGURATION %%%%%%%%%%%%%%
%数学函数库配置
% set up the blas/lapack library you want to use. Possible choices are
%   - builtin: blas/lapack shipped with Matlab, 
%           same as mex: good choice if matlab is correctly configured.
%   - mkl: (intel math kernel library), usually the fastest, but not free.
%   - acml: (AMD Core math library), optimized for opteron cpus
%   - blas: (netlib version of blas/lapack), free
%   - atlas: (atlas version of blas/lapack), free,
% ==> you can also tweak this script to include your favorite blas/lapack library
blas='builtin';% 直接使用matlab自带的数学函数库就行

3、MULTITHREADING CONFIGURATION 多线程配置

%%%%%%%%%%%% MULTITHREADING CONFIGURATION %%%%%%%%%%%%%%
%多线程配置
% set true if you want to use multi-threaded capabilities of the toolbox. You
% need an appropriate compiler for that (intel compiler, most recent gcc, or visual studio pro)
use_multithread=false; % (might not compatible with compiler=mex)%上面配置编译器时已经有提示,选择mex,会与'use_multithread=true'有冲突,所以直接配置为false
% if the compilation fails on Mac, try the single-threaded version.
% to run the toolbox on a cluster, it can be a good idea to deactivate this

use_64bits_integers=true;%我的电脑是64bit,所以true。
% use this option if you have VERY large arrays/matrices 
% this option allows such matrices, but may slightly reduce the speed of the computations.

use_mkl_threads=false;
% use this option is you use the mkl library and intends to use intensively BLAS3/lapack routines
% (for multiclass logistic regression, regularization with the trace norm for instance)
% this results in a loss of performance for many other functions

% if you use the options 'mex' and 'builtin', you can proceed with the compilation by
% typing 'compile' in the matlab shell. Otherwise, you need to set up a few path below.

path_matlab='';%上面两行已经说得很清楚,使用mex编译器,直接跳过这里的两个配置即可
%path_matlab='/softs/bin/';

4、PATH CONFIGURATION 路径配置

%%%%%%%%%%%% PATH CONFIGURATION %%%%%%%%%%%%%%%%%%%%

%路径配置
% only if you do not use the options 'mex' and 'builtin'
% set up the path to the compiler libraries that you intend to use below

% 此后一律不动,只有如果使用了其他编译器、数学函数库,才需要改相应的路径

--------------------------------------------------------分割线----------------------------------------------------------------

按上面的过程配置好后,再matlab键入compile运行执行编译。编译过程顺利完成!我们可以看到在build文件夹下,有好多生成的.mexw64文件。


接下来我们进行一个代码运行测试过程,如何使用工具箱内的函数,可以参考刚才提到的doc_spams.pdf文件,里面介绍的比较详细。这里运行test_release/test_TrainDL.m文件做一个测试:

。。。。。。。。。。。。。。。。。。。。。还没运行好,估计计算量比较大吧,应该没问题,就不接着运行了~~



我的这个工具箱安装还挺顺利地呢,是不是从开始就一帆风顺呢???

no~~

我才开始也网上找了不少方法,看了好多博客(下面会给出参考博客的,参考博客包含一些遇到错误的解决方法~~)啥的,走了好多弯路,上面的是记录我的安装配置的一种情况,供大家分享交流~~

参考博客:

https://chunqiu.blog.ustc.edu.cn/?p=570

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 削山药皮皮肤痒怎么办 脊柱侧弯20度怎么办 27岁脊柱侧弯怎么办 右侧侧脑室增宽怎么办 左侧脑室增宽该怎么办 腿上的血管堵塞怎么办 做b超看不清骶尾怎么办 孕中期羊水过少怎么办 心脏办膜关闭不全怎么办 9个月胎儿脑积水怎么办 怀孕三个月胎盘低置怎么办 怀孕第一个月打针了怎么办 唐氏筛查神经管缺陷高风险怎么办 门诊处方笺丢了怎么办 孕中期睡觉手麻怎么办 怀孕2个月了没胎心胎芽怎么办 怀孕腿疼的厉害怎么办 孕妇老是失眠多梦怎么办 孕妇会失眠多梦怎么办 怀孕5个月睡不着怎么办 6个月孕妇失眠怎么办 彩超脉络丛囊肿怎么办 双侧脉络丛囊肿怎么办 唐筛神经管缺陷高风险怎么办 雌激素低怎么办吃什么东西补 我怀了狗的孩子怎么办 结婚2年不要孩子怎么办 备孕一直没怀孕怎么办 刚生的婴儿打嗝怎么办 小孩40天黄疸高怎么办 婴儿身高长得慢怎么办 四个月的宝宝哭怎么办 孕39周羊水偏多怎么办 孕39周羊水浑浊怎么办 孕晚期羊水过少怎么办 怀孕脐带绕颈一周怎么办 nt检查宝宝趴着怎么办 四维胎儿有问题怎么办 怀孕70天没有胎心怎么办 怀孕20天不想要怎么办 换轮胎胎压监测怎么办