您的位置:首页 > 其它

shogun-toolbox的使用方法和问题总结

2016-09-30 15:39 363 查看
本以为在上一次安装入坑之后能顺利使用,没想到在matlab接口具体使用时又出现了问题,接下来我将一一进行说明.

上一篇shogun-toolbox的安装与问题总结

1. matlab接口示例代码生成

这块内容一定是shogun的新手遇到的头疼的问题,找不到切入点,没办法模仿示例代码进行改写.一开始我也是摸不着头脑,后来就看shogun包中的doc/cookbook,但发现里面压根没有关于matlab的示例.所有又在包中到处寻找,直到看到了example/README.md和example/generate_documented.sh文件才算找到了希望.

$ cd shogun/examples
$ ./generate_documented.sh


生成示例代码,我们可以在examples/documented/matlab_static下看到示例代码.

2. matlab示例代码执行问题处理

在matlab中执行示例代码时,遇到了如下错误:

>> svr_regression
Invalid MEX-file '/home/slave/kernel/shogun410/build/src/interfaces/matlab_static/sg.mexa64':
libshogun.so.17: cannot open shared object file: No such file or directory

Error in svr_regression (line 6)
sg('set_features', 'TRAIN', traindat);


matlab
无法找到
libshogun.so.17
文件. 在github上找到了相关的问题https://github.com/shogun-toolbox/shogun/issues/2344,shogun的维护者说是没有配置
LD_LIBRARY_PATH
变量导致的(其实这个问题在安装教程里就提到过https://github.com/shogun-toolbox/shogun/wiki/INSTALL#general,只是我当时没有注意).

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:path_to_shogun/src/shogun/


然后,再次执行示例代码,这次又出现了新的问题.

>> svr_regression
Invalid MEX-file '/home/slave/kernel/shogun410/build/src/interfaces/matlab_static/sg.mexa64':
/usr/local/MATLAB/R2012b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not
found (required by /usr/local/lib/libshogun.so.17)

Error in svr_regression (line 6)
sg('set_features', 'TRAIN', traindat);


这次又是与
libstdc++.so.6
相关的问题,在网上搜索了相关的解决方案,最终解决.

首先,我们需要定位系统中的
libstdc++.so.6
所在位置 ,然后我们将该位置的
libstdc++.so.6
文件链接到matlab中.

$ locate libstdc++.so.6
/home/slave/Downloads/matlab/bin/glnxa64/libstdc++.so.6
/home/slave/Downloads/matlab/bin/glnxa64/libstdc++.so.6.0.13
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
/usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6
/usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6.0.13
/usr/local/MATLAB/R2012b/toolbox/sldv/sldv/polyspace-dvo/lib/x86-linux/libstdc++.so.6
/usr/local/MATLAB/R2012b/toolbox/sldv/sldv/polyspace-dvo/lib/x86-linux/libstdc++.so.6.0.13
/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py


我们可以发现系统中的
libstdc++.so.6
文件路径在
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
.将matlab中的文件备份,做链接.

$ sudo mv /usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6 /usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6.bak

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/MATLAB/R2012b/sys/os/glnxa64/libstdc++.so.6


然后,重新启动matlab运行
svr_regression
示例代码.得到一下信息,并绘制出图像.OK,大功告成.

libshogun (x86_64/v4.1.0_2016-2-10_18:33262400)

Copyright (C) 1999-2009 Fraunhofer Institute FIRST
Copyright (C) 1999-2011 Max Planck Society
Copyright (C) 2009-2011 Berlin Institute of Technology
Copyright (C) 2012-2014 Soeren Sonnenburg, Sergey Lisitsyn, Heiko Strathmann, Viktor Gal, Fernando Iglesias et al
Written   (W) 1999-2012 Soeren Sonnenburg, Gunnar Raetsch et al.

( configure options: "TODO" compile flags: "-Wall -Wno-unused-parameter -Wformat -Wformat-security -Wparentheses -Wshadow -Wno-unknown-pragmas -Wno-deprecated  -fopenmp  -O3 -fexpensive-optimizations -frerun-cse-after-loop -fcse-follow-jumps -finline-functions -fschedule-insns2 -fthread-jumps -fforce-addr -fstrength-reduce -funroll-loops -mfpmath=sse" link flags: "-lpthread" )
( seeding random number generator with 0 (seed size 256))
determined range for x in log(1+exp(-x)) is:37 )


其实,我在github上都提问了https://github.com/shogun-toolbox/shogun/issues/3453,但是自己解决掉了问题,属于自问自答型.

参考:

https://github.com/shogun-toolbox/shogun/wiki/INSTALL

https://github.com/shogun-toolbox/shogun/issues/2344

http://blog.csdn.net/woyaopojie1990/article/details/28426013

https://github.com/shogun-toolbox/shogun/issues/3453
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: