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

📄 demolin8.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">Adaptive Noise Cancellation</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">A linear neuron is allowed to adapt so that given one signal, it can predict asecond signal.</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">Copyright 1992-2002 The MathWorks, Inc.$Revision: 1.13 $  $Date: 2002/03/29 19:36:13 $</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">TIME defines the time steps of this simulation.  P defines a signal over thesetime steps.  T is a signal derived from P by shifting it to the left,multiplying it by 2 and adding it to itself.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">time = 1:0.01:2.5;X = sin(sin(time).*time*10);P = con2seq(X);T = con2seq(2*[0 X(1:(end-1))] + X);</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">Here is how the two signals are plotted:</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">plot(time,cat(2,P{:}),time,cat(2,T{:}),<span style="color:#B20000">'--'</span>)title(<span style="color:#B20000">'Input and Target Signals'</span>)xlabel(<span style="color:#B20000">'Time'</span>)legend({<span style="color:#B20000">'Input'</span>,<span style="color:#B20000">'Target'</span>})</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demolin8_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 linear network must have tapped delay in order to learn the time-shiftedcorrelation between P and T.  NEWLIN creates a linear layer.  [-3 3] is theexpected input range.  The second argument is the number of neurons in thelayer.  [0 1] specifies one input with no delay and one input with a delay ofone.  The last argument is the learning rate.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">net = newlin([-3 3],1,[0 1],0.1);</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">ADAPT simulates adaptive networks.  It takes a nework, a signal, and a targetsignal, and filters the signal adaptively.  Plot the the output Y in blue, thetarget T in red and the error E in green.  By t=2 the network has learned therelationship between the input and the target  and the error drops to nearzero.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">[net,Y,E,Pf]=adapt(net,P,T);plot(time,cat(2,Y{:}),<span style="color:#B20000">'b'</span>, <span style="color:blue">...</span>   time,cat(2,T{:}),<span style="color:#B20000">'r'</span>, <span style="color:blue">...</span>   time,cat(2,E{:}),<span style="color:#B20000">'g'</span>,[1 2.5],[0 0],<span style="color:#B20000">'k'</span>)legend({<span style="color:#B20000">'Output'</span>,<span style="color:#B20000">'Target'</span>,<span style="color:#B20000">'Error'</span>})</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demolin8_img05.gif"><originalCode xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" code="%% Adaptive Noise Cancellation&#xA;% A linear neuron is allowed to adapt so that given one signal, it can predict a&#xA;% second signal.&#xA;% &#xA;% Copyright 1992-2002 The MathWorks, Inc.&#xA;% $Revision: 1.13 $  $Date: 2002/03/29 19:36:13 $&#xA;&#xA;%%&#xA;% TIME defines the time steps of this simulation.  P defines a signal over these&#xA;% time steps.  T is a signal derived from P by shifting it to the left,&#xA;% multiplying it by 2 and adding it to itself.&#xA;&#xA;time = 1:0.01:2.5;&#xA;X = sin(sin(time).*time*10);&#xA;P = con2seq(X);&#xA;T = con2seq(2*[0 X(1:(end-1))] + X);&#xA;&#xA;%%&#xA;% Here is how the two signals are plotted:&#xA;&#xA;plot(time,cat(2,P{:}),time,cat(2,T{:}),'--')&#xA;title('Input and Target Signals')&#xA;xlabel('Time')&#xA;legend({'Input','Target'})&#xA;&#xA;%%&#xA;% The linear network must have tapped delay in order to learn the time-shifted&#xA;% correlation between P and T.  NEWLIN creates a linear layer.  [-3 3] is the&#xA;% expected input range.  The second argument is the number of neurons in the&#xA;% layer.  [0 1] specifies one input with no delay and one input with a delay of&#xA;% one.  The last argument is the learning rate.&#xA;&#xA;net = newlin([-3 3],1,[0 1],0.1);&#xA;&#xA;%%&#xA;% ADAPT simulates adaptive networks.  It takes a nework, a signal, and a target&#xA;% signal, and filters the signal adaptively.  Plot the the output Y in blue, the&#xA;% target T in red and the error E in green.  By t=2 the network has learned the&#xA;% relationship between the input and the target  and the error drops to near&#xA;% zero.&#xA;&#xA;[net,Y,E,Pf]=adapt(net,P,T);&#xA;plot(time,cat(2,Y{:}),'b', ...&#xA;   time,cat(2,T{:}),'r', ...&#xA;   time,cat(2,E{:}),'g',[1 2.5],[0 0],'k')&#xA;legend({'Output','Target','Error'})&#xA;"></originalCode>

⌨️ 快捷键说明

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