📄 demop6.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">Linearly Non-separable Vectors</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">A 2-input hard limit neuron fails to properly classify 5 input vectors becausethey are linearly non-separable.</p><p xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd">Copyright 1992-2002 The MathWorks, Inc.$Revision: 1.15 $ $Date: 2002/03/29 19:36:08 $</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">Each of the five column vectors in P defines a 2-element input vectors, and arow vector T defines the vector's target categories. Plot these vectors withPLOTPV.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">P = [ -0.5 -0.5 +0.3 -0.1 -0.8; <span style="color:blue">...</span> -0.5 +0.5 -0.5 +1.0 +0.0 ];T = [1 1 0 0 0];plotpv(P,T);</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demop6_img02.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 perceptron must properly classify the input vectors in P into thecategories defined by T. Because the two kinds of input vectors cannot beseparated by a straight line, the perceptron will not be able to do it. NEWPcreates a perceptron.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">net = newp([-40 1;-1 50],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">Add the the neuron's initial attempt at classification to the plot. Theinitial weights are set to zero, so any input gives the same output and theclassification line does not even appear on the plot.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">hold onplotpv(P,T);linehandle=plotpc(net.IW{1},net.b{1});</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demop6_img04.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">ADAPT returns a new network object that performs as a better classifier, thenetwork outputs, and the error. This loop allows the network to adapt for 3passes, plots the classification line, and stops after 25 iterations.</p><pre xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" style="position: relative; left:30px">net.adaptParam.passes = 3;linehandle=plotpc(net.IW{1},net.b{1});<span style="color:blue">for</span> a = 1:25 [net,Y,E] = adapt(net,P,T); linehandle = plotpc(net.IW{1},net.b{1},linehandle); drawnow;<span style="color:blue">end</span>;</pre><img xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" src="demop6_img05.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">Note that zero error was never obtained. Despite training, the perceptron hasnot become an acceptable classifier. Only being able to classify linearlyseparable data is the fundamental limitation of perceptrons.</p><originalCode xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd" code="%% Linearly Non-separable Vectors
% A 2-input hard limit neuron fails to properly classify 5 input vectors because
% they are linearly non-separable.
%
% Copyright 1992-2002 The MathWorks, Inc. 
% $Revision: 1.15 $ $Date: 2002/03/29 19:36:08 $

%%
% Each of the five column vectors in P defines a 2-element input vectors, and a
% row vector T defines the vector's target categories. Plot these vectors with
% PLOTPV.

P = [ -0.5 -0.5 +0.3 -0.1 -0.8; ...
 -0.5 +0.5 -0.5 +1.0 +0.0 ];
T = [1 1 0 0 0];
plotpv(P,T);

%%
% The perceptron must properly classify the input vectors in P into the
% categories defined by T. Because the two kinds of input vectors cannot be
% separated by a straight line, the perceptron will not be able to do it. NEWP
% creates a perceptron.

net = newp([-40 1;-1 50],1);

%%
% Add the the neuron's initial attempt at classification to the plot. The
% initial weights are set to zero, so any input gives the same output and the
% classification line does not even appear on the plot.

hold on
plotpv(P,T);
linehandle=plotpc(net.IW{1},net.b{1});

%%
% ADAPT returns a new network object that performs as a better classifier, the
% network outputs, and the error. This loop allows the network to adapt for 3
% passes, plots the classification line, and stops after 25 iterations.

net.adaptParam.passes = 3;
linehandle=plotpc(net.IW{1},net.b{1});
for a = 1:25
 [net,Y,E] = adapt(net,P,T);
 linehandle = plotpc(net.IW{1},net.b{1},linehandle); drawnow;
end;

%%
% Note that zero error was never obtained. Despite training, the perceptron has
% not become an acceptable classifier. Only being able to classify linearly
% separable data is the fundamental limitation of perceptrons.
"></originalCode>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -