如何在libsvm中保存matlab训练的模型

我刚开始使用libsvm和matlab。我从网站上下载了libsvm 3.17版本,并使用Matlab训练了我的数据集。我想保存文件,于是使用了svm_savemodel.c,但它在matlab中无法编译。我收到的错误信息如下:

mex svm_savemodel.cCreating library C:\Users\mark\AppData\Local\Temp\mex_zcr67j\templib.x and object C:\Users\mark\AppData\Local\Temp\mex_zcr67j\templib.exp svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_free_and_destroy_model referenced in function _mexFunction svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_save_model referenced in function _mexFunction svm_savemodel.obj : error LNK2019: unresolved external symbol _matlab_matrix_to_model referenced in function _mexFunction svm_savemodel.mexw32 : fatal error LNK1120: 3 unresolved externals C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Link of 'svm_savemodel.mexw32' failed. Error using mex (line 206)Unable to complete successfully.

所以,有谁能帮我解决这个问题吗?我已经包含了svm.h, mex.h, svm_model_matlab.h,但它仍然拒绝编译…

这是我所做的操作:

    >> mex -setupWelcome to mex -setup.  This utility will help you set up  a default compiler.  For a list of supported compilers, see  http://www.mathworks.com/support/compilers/R2011b/win32.html Please choose your compiler for building MEX-files: Would you like mex to locate installed compilers [y]/n? ySelect a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011b\sys\lcc [2] Microsoft Visual C++ 2010 in C:\Program Files\Microsoft Visual Studio 10.0 [0] None Compiler: 2Please verify your choices: Compiler: Microsoft Visual C++ 2010  Location: C:\Program Files\Microsoft Visual Studio 10.0 Are these correct [y]/n? y***************************************************************************   Warning: MEX-files generated using Microsoft Visual C++ 2010 require            that Microsoft Visual Studio 2010 run-time libraries be             available on the computer they are run on.            If you plan to redistribute your MEX-files to other MATLAB            users, be sure that they have the run-time libraries. *************************************************************************** Trying to update options file: C:\Users\michael\AppData\Roaming\MathWorks\MATLAB\R2011b\mexopts.bat From template:              C:\PROGRA~1\MATLAB\R2011b\bin\win32\mexopts\msvc100opts.bat Done . . . **************************************************************************   Warning: The MATLAB C and Fortran API has changed to support MATLAB            variables with more than 2^32-1 elements.  In the near future            you will be required to update your code to utilize the new            API. You can find more information about this at:            http://www.mathworks.com/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9            Building with the -largeArrayDims option enables the new API. ************************************************************************** >> cd('C:\libsvm-3.17\libsvm-3.17\matlab');>> make>> mex svm_savemodel.c   Creating library C:\Users\michael\AppData\Local\Temp\mex_coX2K1\templib.x and object C:\Users\michael\AppData\Local\Temp\mex_coX2K1\templib.exp svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_free_and_destroy_model referenced in function _mexFunction svm_savemodel.obj : error LNK2019: unresolved external symbol _svm_save_model referenced in function _mexFunction svm_savemodel.obj : error LNK2019: unresolved external symbol _matlab_matrix_to_model referenced in function _mexFunction svm_savemodel.mexw32 : fatal error LNK1120: 3 unresolved externals   C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Link of 'svm_savemodel.mexw32' failed. Error using mex (line 206)Unable to complete successfully.>> 

回答:

将以下内容添加到你的make.m文件中(你可以将它们添加到ifelse部分):

mex CFLAGS="$CFLAGS -std=c99" -largeArrayDims svm_savemodel.c ../svm.cpp svm_model_matlab.c

Related Posts

Keras Dense层输入未被展平

这是我的测试代码: from keras import…

无法将分类变量输入随机森林

我有10个分类变量和3个数值变量。我在分割后直接将它们…

如何在Keras中对每个输出应用Sigmoid函数?

这是我代码的一部分。 model = Sequenti…

如何选择类概率的最佳阈值?

我的神经网络输出是一个用于多标签分类的预测类概率表: …

在Keras中使用深度学习得到不同的结果

我按照一个教程使用Keras中的深度神经网络进行文本分…

‘MatMul’操作的输入’b’类型为float32,与参数’a’的类型float64不匹配

我写了一个简单的TensorFlow代码,但不断遇到T…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注