An Efficient Projection for l1,∞ Regularization該文提供代碼,在Readme文件中說To run the projection in Matlab, you first need to compile the mexfile:
Then, from Matlab, test the projection by running the script "runprojection",
(1)在我筆記本電腦,打開matlab,打開該程序所在的文件夾,在matlab命令行輸入mex -setup,
matlab輸出:Would you like mex to locate installed compilers [y]/n?
手動輸入:y ,
matlab輸出:
Select a compiler:
手動輸入:1, matlab輸出: Are these correct [y]/n?
手動輸入:y 。
手動輸入: mex -output projL1Inf mex-projL1Inf.c ,可能是因為我的筆記本電腦沒裝VC,有錯誤。在我本機要能運行,關鍵就是生成
projL1Inf.mexw32這個文件就可以了,在Mingming Gong電腦上生成,拷貝到我的電腦就可以了。 Mingming電腦裝VC了,但還是不能編譯,他講可能原因是這個c語言代碼本來就是在linux下寫的,在windows上跑不了,naiyang也這么說。
20121023, after Mingming Gong saw my blog, he found the solution to produce the file projL1Inf.mexw32. 只要將mex-projL1Inf.c后綴改為mex-projL1Inf.cpp,projL1Inf.c后綴改為projL1Inf.cpp,mex-projL1Inf.cpp第39行改為#include "projL1Inf.cpp",只要修改這三點就可以在windows下編譯,我已經從他那里拷貝了
projL1Inf.mexw32 。從我本機還是不能編譯,因為本機沒裝VC。
原因:*.cpp是支持C和C++的;*.c只支持C,故//不支持。在Linux下C和C++是兩個編譯器(在linux下c是用gcc編譯,C++使用g++編譯),在windows下,C和C++是可以同時用VC編譯的。
20130629在NLPR的54服務器用mex -output projL1Inf mex-projL1Inf.cpp成功編譯生成文件projL1Inf.mexw64,不知為什么用mex -setup一步一步來不行。
(2)在uts cluster,按照上面輸入的命令,有錯誤和警告 (Mingming said that the warning does not matter)
Warning: You are using gcc version "4.4.6". The version
currently supported with MEX is "4.3.4".
錯誤:projL1Inf.c:248: error: expected expression before '/' token
projL1Inf.c:250: error: expected expression before '/' token
projL1Inf.c:252: error: expected expression before '/' token
打開projL1Inf.c ,將這三行的注釋//,均換成/* * /
這樣的作用,就是生成
projL1Inf.mexa64這個文件.如果用命令mex mex-projL1Inf.c,就是生成
mex-projL1Inf.mexa64 (已經實踐,將原始 projL1Inf.mexa64 刪除,用命令mex mex-projL1Inf.c,就是生成
mex-projL1Inf.mexa64, 再將這個文件改名為projL1Inf.mexa64,再運行runprojection 還是可以的)
20121208在uts服務器編譯libsvm-mat-2.9-1,編譯有問題,根據提示,將所有文件*.c都變成*.cpp,還有問題g++: svm.obj: No such file or directory,上網搜索解決方案http://blog.csdn.net/kit_147/article/details/7417734,將文件svm.obj改為svm.o,編譯就沒有問題了,但用程序測試還有問題,提示 "-largeArrayDims"的問題,make.m開始注釋:% add -largeArrayDims on 64-bit machines,問mingming gong怎么add?將makefile中的mex...修改為mex...-largeArrayDims即可。例如
mex -O -c svm.cpp
mex -O -c svm_model_matlab.c
修改為
mex -O -c svm.cpp -largeArrayDims
mex -O -c svm_model_matlab.c -largeArrayDims
(This is with Mingming Gong's help)
20150710在跑FastHash提示錯誤:binaryTreeTrain1.mexw64不是有效的w32應用程序,感到費解,這是64位機,怎么會提示這個錯誤。Jian Liang講重新編譯下就行了,他就在matlab窗口敲入mex binaryTreeTrain1.cpp,再敲入mex forestInds.cpp就可以了