How can I get a decent number of samples VS train error graph in neural networks?

조회 수: 1 (최근 30일)
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
% initialize the net
net = init(net);
% parameters are choosen
net.trainParam.epochs = 20;
net.trainParam.max_fail = 6;
% train the net
% simulate the net
% record the errors and corresponding number of samples
tperf(ctr) = tr.best_tperf;
bestperf(ctr) = tr.best_perf;
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개)


Help CenterFile 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!

Translated by