⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demolin1.html

📁 神经网络学习过程的实例程序
💻 HTML
字号:
<!--This HTML is auto-generated from an m-file.Your changes will be overwritten.--><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:x-large">Pattern Association Showing Error Surface</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">A linear neuron is designed to respond to specific inputs with target outputs.</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">Copyright 1992-2002 The MathWorks, Inc.$Revision: 1.14 $  $Date: 2002/03/29 19:36:19 $</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:medium; page-break-before: auto;"><a name=""></a></p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">P defines two 1-element input patterns (column vectors).  T defines theassociated 1-element targets (column vectors).</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">P = [1.0 -1.2];T = [0.5 1.0];</pre><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:medium; page-break-before: auto;"><a name=""></a></p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">ERRSURF calculates errors for a neuron with a range of possible weight andbias values.  PLOTES plots this error surface with a contour plot underneath.The best weight and bias values are those that result in the lowest point onthe error surface.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">w_range = -1:0.1:1;b_range = -1:0.1:1;ES = errsurf(P,T,w_range,b_range,<span style="color:#B20000">'purelin'</span>);plotes(w_range,b_range,ES);</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demolin1_img03.gif"><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:medium; page-break-before: auto;"><a name=""></a></p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">The function NEWLIND will design a network that performs with the minimumerror.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">net = newlind(P,T);</pre><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:medium; page-break-before: auto;"><a name=""></a></p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">SIM is used to simulate the network for inputs P.  We can then calculate theneurons errors.  SUMSQR adds up the squared errors.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">A = sim(net,P)E = T - ASSE = sumsqr(E)</pre><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:gray; font-style:italic;">A =    0.5000    1.0000E =     0     0SSE =     0</pre><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:medium; page-break-before: auto;"><a name=""></a></p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">PLOTES replots the error surface.  PLOTEP plots the "position" of the networkusing the weight and bias values returned by SOLVELIN.  As can be seen fromthe plot, SOLVELIN found the minimum error solution.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">plotes(w_range,b_range,ES);plotep(net.IW{1,1},net.b{1},SSE);</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demolin1_img06.gif"><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:#990000; font-weight:bold; font-size:medium; page-break-before: auto;"><a name=""></a></p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">We can now test the associator with one of the original inputs, -1.2, and seeif it returns the target, 1.0.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">p = -1.2;a = sim(net,p)</pre><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="color:gray; font-style:italic;">a =     1</pre><originalCode xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" code="%% Pattern Association Showing Error Surface&#xA;% A linear neuron is designed to respond to specific inputs with target outputs.&#xA;% &#xA;% Copyright 1992-2002 The MathWorks, Inc.&#xA;% $Revision: 1.14 $  $Date: 2002/03/29 19:36:19 $&#xA;&#xA;%%&#xA;% P defines two 1-element input patterns (column vectors).  T defines the&#xA;% associated 1-element targets (column vectors).&#xA;&#xA;P = [1.0 -1.2];&#xA;T = [0.5 1.0];&#xA;&#xA;%%&#xA;% ERRSURF calculates errors for a neuron with a range of possible weight and&#xA;% bias values.  PLOTES plots this error surface with a contour plot underneath.&#xA;% The best weight and bias values are those that result in the lowest point on&#xA;% the error surface.&#xA;&#xA;w_range = -1:0.1:1;&#xA;b_range = -1:0.1:1;&#xA;ES = errsurf(P,T,w_range,b_range,'purelin');&#xA;plotes(w_range,b_range,ES);&#xA;&#xA;%%&#xA;% The function NEWLIND will design a network that performs with the minimum&#xA;% error.&#xA;&#xA;net = newlind(P,T);&#xA;&#xA;%%&#xA;% SIM is used to simulate the network for inputs P.  We can then calculate the&#xA;% neurons errors.  SUMSQR adds up the squared errors.&#xA;&#xA;A = sim(net,P)&#xA;E = T - A&#xA;SSE = sumsqr(E)&#xA;&#xA;%%&#xA;% PLOTES replots the error surface.  PLOTEP plots the &#34;position&#34; of the network&#xA;% using the weight and bias values returned by SOLVELIN.  As can be seen from&#xA;% the plot, SOLVELIN found the minimum error solution.&#xA;&#xA;plotes(w_range,b_range,ES);&#xA;plotep(net.IW{1,1},net.b{1},SSE);&#xA;&#xA;&#xA;&#xA;%%&#xA;% We can now test the associator with one of the original inputs, -1.2, and see&#xA;% if it returns the target, 1.0.&#xA;&#xA;p = -1.2;&#xA;a = sim(net,p)&#xA;"></originalCode>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -