program takes long time to run
이전 댓글 표시
I have a code below,which takes long time to run,can u tell how to process please....
Gout is my input which contains 990 rows and 4 colomns of data(990*4)
Ng=Gout
hidden_neurons =6;
epochs = 100;
wait_l = epochs*Nf;
wait_i = 0;
%h = waitbar(0,'Training Neural Network');
for i = 1:Nf
st = (i-1)*round(size(Traindata,1)/Nf)+1;
en = i*round(size(Traindata,1)/Nf);
if en>size(Traindata,1)
en=size(Traindata,1);
end
train_inp = [Traindata(1:st-1,:);Traindata(en+1:end,:)];
train_out = [Trainlabel(1:st-1,:);Trainlabel(en+1:end,:)];
test_inp = Traindata(st:en,:);
[Predicted,wait_i] = Neural1(hidden_neurons, epochs, train_inp, train_out, test_inp, wait_l, wait_i);
Training_error_NN(i,:) = sum(abs(Predicted-Trainlabel(st:en,:)));
Training_acc_NN(i,:) = accuracy(Predicted,Trainlabel(st:en,:));
end
% close(h);
pause(1);
%wait_i = 0;
%h = waitbar(0,'Testing Neural Network');
for i = 1:Nf
st = (i-1)*round(size(Testdata,1)/Nf)+1;
en = i*round(size(Testdata,1)/Nf);
if en>size(Testdata,1)
en=size(Testdata,1);
end
train_inp = Traindata;
train_out = Trainlabel;
test_inp = Testdata(st:en,:);
[Predicted,wait_i] = Neural1(hidden_neurons, epochs, train_inp, train_out, test_inp, wait_l, wait_i);
Testing_error_NN(i) = sum(abs(Predicted-Testlabel(st:en,:)));
Testing_acc_NN(i) = accuracy(Predicted,Testlabel(st:en,:));
(Testing_acc_NN')
(Testing_error_NN')
result=[fc1 Testing_acc_NN' Testing_error_NN']
end
% close(h);
pause(1);
채택된 답변
추가 답변 (1개)
Lulu
2011년 11월 1일
0 개 추천
If Nf is large, then try to vectorize FOR loop.
댓글 수: 1
Jan
2011년 11월 1일
I wouldn't do this. The creation of large temporary arrays is usually more time-consuming than the accleration by the vectorization. The vectorization is helpful, if the data are available as arrays already.
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!