Как сохранить обученную модель Matlab в libsvm

0

Я новичок в libsvm и matlab. Я загрузил libsvm 3.17 с веб-сайта и обучил мой набор данных с помощью Matlab. Я хотел сохранить файл, и я использовал svm_savemodel.c, который отказался компилировать в matlab. Это сообщение, которое я получаю

mex svm_savemodel.c
Creating 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 -setup

Welcome 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? y

Select 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: 2

Please 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.

>> 
  • 0
    Вы читали документацию о том, как построить библиотеку. Если нет, я очень рекомендую это. github.com/cjlin1/libsvm/tree/master/matlab Я также даю эту рекомендацию для любых дальнейших вопросов по SO. Прочитайте документацию, прежде чем задавать вопросы, на которые можно легко ответить, выполнив именно это
  • 0
    Да, я прочитал файл README, который был найден в ZIP. Фактически, другие файлы C, найденные в папке matlab, скомпилированы успешно. Именно этот файл возвращает эту ошибку.
Показать ещё 2 комментария
Теги:
machine-learning
libsvm

1 ответ

0
Лучший ответ

добавьте в ваш make.m файл (вы можете добавить их как if и else часть):

mex CFLAGS="$CFLAGS -std=c99" -largeArrayDims svm_savemodel.c ../svm.cpp svm_model_matlab.c
  • 0
    Добавляя \ infront $ CFLAGS ... это работает !! Большое спасибо!
  • 0
    добро пожаловать!

Ещё вопросы

Сообщество Overcoder
Наверх
Меню