Parfor loop problem with SVM classification

Hi. I have a problem for paralleling a SVM Classification. In my code I repeat 3 times a 5-fold cross validation of SVM and average the accuracy of it. I want to paralell the main loop of 3 times repeat of cross validation but when I use parfor in this loop the program doesn't use all performance of 2 Cores of my CPU and only use 60% of the performance!.
Thank you so much
Code :
parfor L=1:NumOFLoops;
indices = crossvalind('Kfold',QQ,NumOfKfold);
cp = classperf(QQ);
for m=1:NumOfKfold;
test = (indices == m); Train = ~test;
testI=zeros(numel(test>0),1);
TrainInputs=INPUT(Train,:);
TrainTargets=QQ(Train,:);
TestInputs=INPUT(test,:);
%%SVM Structure
svmstruct=svmtrain(TrainInputs,TrainTargets,...
'boxconstraint',Penalty,...
'kernel_function','rbf','method','QP',...
'rbf_sigma',Sigma)
TestOutputs=svmclassify(svmstruct,TestInputs,'showplot',false);
classperf(cp,TestOutputs,test);
end
Error(:,L)=cp.ErrorRate;
end
Results.ErrorRate=(sum(Error))/NumOFLoops;

 採用された回答

Edric Ellis
Edric Ellis 2013 年 11 月 14 日

0 投票

If you're using R2013a or earlier, you need to explicitly open a matlabpool before running the PARFOR loop using "matlabpool('local', 2)". R2013b does this for you automatically.
Also, if you only have 3 iterations that can run in parallel, the best speedup you can hope for is 1.5 since one worker will have to perform two of the iterations.

2 件のコメント

Eghbal
Eghbal 2013 年 11 月 14 日
編集済み: Eghbal 2013 年 11 月 14 日
Thank you so much for your reply. Yes. I'm suing R2013b. I increase numbers of parfor loop to 8 but the max performance in two cores in Task Manager is 73-75!. Two matlab in task manager are running.Two 32-35% processing. When I compared it with normal processing(1 core), the total performance is similar in two cases. for and parfor.
Thanks,
Edric Ellis
Edric Ellis 2013 年 11 月 25 日
It's possible then that the performance of your loop is limited by memory bandwidth rather than by CPU utilisation.

サインインしてコメントする。

その他の回答 (1 件)

Eghbal
Eghbal 2013 年 11 月 20 日
編集済み: Eghbal 2013 年 11 月 20 日

0 投票

I checked this problem with other classification & regression methods like MLP neural network (Newff) and other, but i have same problem.
Thanks,

カテゴリ

ヘルプ センター および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

質問済み:

2013 年 11 月 14 日

コメント済み:

2013 年 11 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by