How can I get a decent number of samples VS train error graph in neural networks?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello;
I am trying to obtain the graph for number of samples VS training error. The graph I would like to have is like this

I am trying to do this by using the batch training with 'trainlm' algorithm. The code I have written is the following:
clc, clear all, close all;
for ctr=1:20
% number of samples is ctr
input = linspace(-3,3,ctr);
Target = tanh(input);
% define the net
net=feedforwardnet(1,'trainlm');
% initialize the net
net = init(net);
% parameters are choosen
net.trainParam.epochs = 20;
net.trainParam.max_fail = 6;
% train the net
[net,tr]=train(net,input,Target);
% simulate the net
Y=sim(net,input);
% record the errors and corresponding number of samples
tperf(ctr) = tr.best_tperf;
bestperf(ctr) = tr.best_perf;
end
plot(tperf) xlabel('number of samples'); ylabel('error'); hold on plot(bestperf) legend('tperf','bestperf')
As you can see the error values are saved into an array with corresponding number of samples. However I end up with the graph like that:

It really makes sense that as the number of samples increases the training error will converge to some number, however I cannot do it in my code.
I am looking for your answer.
Yours Sincerely.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!