필터 지우기
필터 지우기

How to unable data division in net training?

조회 수: 1 (최근 30일)
sara
sara 2017년 1월 30일
I want to classify 11 different hand motions using patternnet and validate the result using 10-fold cross validation (9 for train and 1 for test). How can I unable data division in the training process? Is it ok to do that? My code is as follow:
load FeatureSet;
p=input; %[16 by 1342 ]
t=target; %[11 by 1342]
Nk=1342/11;
labels=[ones(Nk,1); 2.*ones(Nk,1); 3.*ones(Nk,1); 4.*ones(Nk,1); 5.*ones(Nk,1); 6.*ones(Nk,1); 7.*ones(Nk,1); 8.*ones(Nk,1); 9.*ones(Nk,1); 10.*ones(Nk,1); 11.*ones(Nk,1)];
kfold=10;
indices = crossvalind('Kfold',labels,kfold);
for i = 1:kfold
ts = (indices == i); tr = ~ts;
Ptr = p(tr,:); Pts = p(ts,:);
Ttr=t(tr,:); Tts = t(ts,:);
trainFcn = 'trainbr';
net = patternnet([32 32], trainFcn);
net.layers{1}.transferFcn = 'tansig'; % hidden layer 1
net.layers{2}.transferFcn = 'tansig'; % hidden layer 2
% %------------------------parameter
net.trainParam.lr = 0.1; %learning rate
net.trainParam.mc = 0.1; %momentum
%------------------------ train
[net,tr]= train(net,Ptr,Ttr);
%------------------------ test
outputs= sim(net,Pts);
[c,cm] = confusion(Tts,outputs);
pct(i)=100*(1-c); %correction rate
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by