Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: save net after training

Subject: save net after training

From: Mike

Date: 18 Jul, 2008 07:02:53

Message: 1 of 3

Hi

I have studied Sample Training Session in neural network toolbox.
Codes are:

 load choles_all
%reset random number generator. Otherwise, one gets different results
every
%time.
rand('state',0); randn('state',0);
[pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);
[ptrans,transMat] = prepca(pn,0.001);
[R,Q] = size(ptrans)
iitst = 2:4:Q;
iival = 4:4:Q;
iitr = [1:4:Q 3:4:Q];
val.P = ptrans(:,iival); val.T = tn(:,iival);
test.P = ptrans(:,iitst); test.T = tn(:,iitst);
ptr = ptrans(:,iitr); ttr = tn(:,iitr);

net = newff(minmax(ptr),[5 3],{'tansig' 'purelin'},'trainlm');
[net,tr]=train(net,ptr,ttr,[],[],val,test);

plot(tr.epoch,tr.perf,tr.epoch,tr.vperf,tr.epoch,tr.tperf)
legend('Training','Validation','Test',-1);
ylabel('Squared Error'); xlabel('Epoch');

an = sim(net,ptrans);
a = poststd(an,meant,stdt);
for i=1:3
  figure(i)
  [m(i),b(i),r(i)] = postreg(a(i,:),t(i,:));
end


I have some questions:
1/ Why do we need test data? Aren't test data the same as validation
data?
2/I think one needs to save the training results. Then if I have some
newData, I can use the trained "net" to simulate by using "sim". How
to save "net"?

Thank you in advance.

Mike

Subject: save net after training

From: Greg Heath

Date: 18 Jul, 2008 09:19:03

Message: 2 of 3

On Jul 18, 3:02=A0am, Mike <Sulfate...@gmail.com> wrote:
> Hi
>
> I have studied Sample Training Session in neural network toolbox.
> Codes are:
-----SNIP
> I have some questions:
> 1/ Why do we need test data? =A0Aren't test data the same as validation
> data?

No.

The Design set is composed of
a. the Training subset used to estimate weights and thresholds
b. The Validation subset used to determine when to stop training

Error estimates using training and/or validation data will be biased
because both are used to design the net.

The Test set is used to obtain an unbiased estimate of the
generalization error (i.e., error on nondesign data).

> 2/I think one needs to save the training results. =A0Then if I have some
> newData, I can use the trained "net" to simulate by using "sim". =A0How
> to save "net"?

Sorry, I forgot. Before searching for the answer, try something
like

save net

Hope this helps.

Greg

Subject: save net after training

From: Greg Heath

Date: 18 Jul, 2008 09:22:45

Message: 3 of 3

On Jul 18, 5:19=A0am, Greg Heath <he...@alumni.brown.edu> wrote:
> On Jul 18, 3:02=A0am, Mike <Sulfate...@gmail.com> wrote:
>
> > Hi
>
> > I have studied Sample Training Session in neural network toolbox.
> > Codes are:
> -----SNIP
> > I have some questions:
> > 1/ Why do we need test data? =A0Aren't test data the same as validation
> > data?
>
> No.
>
> The Design set is composed of
> a. the Training subset used to estimate weights and thresholds
> b. The Validation subset used to determine when to stop training
>
> Error estimates using training and/or validation data will be biased
> because both are used to design the net.
>
> The Test set is used to obtain an unbiased estimate of the
> generalization error (i.e., error on nondesign data).
>
> > 2/I think one needs to save the training results. =A0Then if I have som=
e
> > newData, I can use the trained "net" to simulate by using "sim". =A0How
> > to save "net"?
>
> Sorry, I forgot. Before searching for the answer, try something
> like
>
> save net

whoops!

save filename net

produces filename.mat

Hope this helps.

Greg

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics