<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172821</link>
    <title>MATLAB Central Newsreader - save net after training</title>
    <description>Feed for thread: save net after training</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 18 Jul 2008 07:02:53 -0400</pubDate>
      <title>save net after training</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172821#443836</link>
      <author>Mike</author>
      <description>Hi&lt;br&gt;
&lt;br&gt;
I have studied Sample Training Session in neural network toolbox.&lt;br&gt;
Codes are:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;load choles_all&lt;br&gt;
%reset random number generator.  Otherwise, one gets different results&lt;br&gt;
every&lt;br&gt;
%time.&lt;br&gt;
rand('state',0);    randn('state',0);&lt;br&gt;
[pn,meanp,stdp,tn,meant,stdt] = prestd(p,t);&lt;br&gt;
[ptrans,transMat] = prepca(pn,0.001);&lt;br&gt;
[R,Q] = size(ptrans)&lt;br&gt;
iitst = 2:4:Q;&lt;br&gt;
iival = 4:4:Q;&lt;br&gt;
iitr = [1:4:Q 3:4:Q];&lt;br&gt;
val.P = ptrans(:,iival); val.T = tn(:,iival);&lt;br&gt;
test.P = ptrans(:,iitst); test.T = tn(:,iitst);&lt;br&gt;
ptr = ptrans(:,iitr); ttr = tn(:,iitr);&lt;br&gt;
&lt;br&gt;
net = newff(minmax(ptr),[5 3],{'tansig' 'purelin'},'trainlm');&lt;br&gt;
[net,tr]=train(net,ptr,ttr,[],[],val,test);&lt;br&gt;
&lt;br&gt;
plot(tr.epoch,tr.perf,tr.epoch,tr.vperf,tr.epoch,tr.tperf)&lt;br&gt;
legend('Training','Validation','Test',-1);&lt;br&gt;
ylabel('Squared Error'); xlabel('Epoch');&lt;br&gt;
&lt;br&gt;
an = sim(net,ptrans);&lt;br&gt;
a = poststd(an,meant,stdt);&lt;br&gt;
for i=1:3&lt;br&gt;
&amp;nbsp;&amp;nbsp;figure(i)&lt;br&gt;
&amp;nbsp;&amp;nbsp;[m(i),b(i),r(i)] = postreg(a(i,:),t(i,:));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I have some questions:&lt;br&gt;
1/ Why do we need test data?  Aren't test data the same as validation&lt;br&gt;
data?&lt;br&gt;
2/I think one needs to save the training results.  Then if I have some&lt;br&gt;
newData, I can use the trained &quot;net&quot; to simulate by using &quot;sim&quot;.  How&lt;br&gt;
to save &quot;net&quot;?&lt;br&gt;
&lt;br&gt;
Thank you in advance.&lt;br&gt;
&lt;br&gt;
Mike</description>
    </item>
    <item>
      <pubDate>Fri, 18 Jul 2008 09:19:03 -0400</pubDate>
      <title>Re: save net after training</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172821#443857</link>
      <author>Greg Heath</author>
      <description>On Jul 18, 3:02=A0am, Mike &amp;lt;Sulfate...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have studied Sample Training Session in neural network toolbox.&lt;br&gt;
&amp;gt; Codes are:&lt;br&gt;
-----SNIP&lt;br&gt;
&amp;gt; I have some questions:&lt;br&gt;
&amp;gt; 1/ Why do we need test data? =A0Aren't test data the same as validation&lt;br&gt;
&amp;gt; data?&lt;br&gt;
&lt;br&gt;
No.&lt;br&gt;
&lt;br&gt;
The Design set is composed of&lt;br&gt;
a. the Training subset used to estimate weights and thresholds&lt;br&gt;
b. The Validation subset used to determine when to stop training&lt;br&gt;
&lt;br&gt;
Error estimates using training and/or validation data will be biased&lt;br&gt;
because both are used to design the net.&lt;br&gt;
&lt;br&gt;
The Test set is used to obtain an unbiased estimate of the&lt;br&gt;
generalization error (i.e., error on nondesign data).&lt;br&gt;
&lt;br&gt;
&amp;gt; 2/I think one needs to save the training results. =A0Then if I have some&lt;br&gt;
&amp;gt; newData, I can use the trained &quot;net&quot; to simulate by using &quot;sim&quot;. =A0How&lt;br&gt;
&amp;gt; to save &quot;net&quot;?&lt;br&gt;
&lt;br&gt;
Sorry, I forgot. Before searching for the answer, try something&lt;br&gt;
like&lt;br&gt;
&lt;br&gt;
save net&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Fri, 18 Jul 2008 09:22:45 -0400</pubDate>
      <title>Re: save net after training</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172821#443858</link>
      <author>Greg Heath</author>
      <description>On Jul 18, 5:19=A0am, Greg Heath &amp;lt;he...@alumni.brown.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; On Jul 18, 3:02=A0am, Mike &amp;lt;Sulfate...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hi&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I have studied Sample Training Session in neural network toolbox.&lt;br&gt;
&amp;gt; &amp;gt; Codes are:&lt;br&gt;
&amp;gt; -----SNIP&lt;br&gt;
&amp;gt; &amp;gt; I have some questions:&lt;br&gt;
&amp;gt; &amp;gt; 1/ Why do we need test data? =A0Aren't test data the same as validation&lt;br&gt;
&amp;gt; &amp;gt; data?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; No.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The Design set is composed of&lt;br&gt;
&amp;gt; a. the Training subset used to estimate weights and thresholds&lt;br&gt;
&amp;gt; b. The Validation subset used to determine when to stop training&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Error estimates using training and/or validation data will be biased&lt;br&gt;
&amp;gt; because both are used to design the net.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The Test set is used to obtain an unbiased estimate of the&lt;br&gt;
&amp;gt; generalization error (i.e., error on nondesign data).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; 2/I think one needs to save the training results. =A0Then if I have som=&lt;br&gt;
e&lt;br&gt;
&amp;gt; &amp;gt; newData, I can use the trained &quot;net&quot; to simulate by using &quot;sim&quot;. =A0How&lt;br&gt;
&amp;gt; &amp;gt; to save &quot;net&quot;?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Sorry, I forgot. Before searching for the answer, try something&lt;br&gt;
&amp;gt; like&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; save net&lt;br&gt;
&lt;br&gt;
whoops!&lt;br&gt;
&lt;br&gt;
save filename net&lt;br&gt;
&lt;br&gt;
produces filename.mat&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
  </channel>
</rss>

