I have a problem for concurrency with SVM classification. In my code, I repeat 3 times the 5x SVM cross-validation and average its accuracy. I want to paralyze the main loop 3 times repeating cross-validation, but when I use parfor in this loop, the program does not use all the performance of the 2 cores of my processor and uses only 60% of the performance!
Thank you very 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;
source
share