matlab-神经网络-感知器(2)

系统 2428 0

显示函数plotpv的2个参数是输入向量和目标函数

1)

>> P=[0 2 3 1 5 0 6
      2 9 0 7 1 0 0]

P =

     0     2     3     1     5     0     6
     2     9     0     7     1     0     0

>> t=[0 1 0 1 1 0 0]

t =

     0     1     0     1     1     0     0

 

>>plotpv(P,T)


matlab-神经网络-感知器(2)
 

 

 

2)

>> P=[0 2 3 1 5 0 6
2 9 0 7 1 0 0
0 9 2 1 8 0 9]

P =

     0     2     3     1     5     0     6
     2     9     0     7     1     0     0
     0     9     2     1     8     0     9

>> T=[1 0 0 0 0 1 0]

T =

     1     0     0     0     0     1     0

>> plotpv(P,T)
>>


matlab-神经网络-感知器(2)

 

 

3、plotpc返回分界线控点,根据权W和阈值B的输入绘制一条分界线

 

plotpc(W,B)

plotpc(W,B,H)包含从前一次调用中返回的控点,在绘制新分界线之前,删除旧线


 P=[ -0.3 -0.5 +0.6 -0.1 -0.8
-0.5 +0.6 -0.2 +0.5 -0.6 ]
T=[0 1 1 1 0]
plotpv(P,T)
net=newp([-10 2; -5 20],1)
hold on
linehandle=plotpc(net.iw{1},net.b{1})
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

 

 

关于 PLOTPC

 Plot a classification line on a perceptron vector plot.

绘制一个分类线,根据权矩阵W和阈值矩阵B
 
   Syntax
 
     plotpc(W,b)
     plotpc(W,b,h)
 
   Description
 
     PLOTPC(W,B) takes these inputs,
       W - SxR weight matrix (R must be 3 or less).
       B - Sx1 bias vector.
     and returns a handle to a plotted classification line.
  
     PLOTPC(W,B,H) takes these inputs,
       H - Handle to last plotted line.
     and deletes the last line before plotting the new one.
  
     This function does not change the current axis and is intended
     to be called after PLOTPV.
 

 


   Example
 
     The code below defines and plots the inputs and targets for a
     perceptron:
 
       p = [0 0 1 1; 0 1 0 1];
       t = [0 0 0 1];
       plotpv(p,t)
 下面的代码创建一个感知器,感知器是单层神经元,采用阈值激活函数,对一组输入向量的响应达到 元素为0或1的目标输出,实现对输入向量进行分类,下面这个代码创建了这个分类线
     The following code creates a perceptron with inputs ranging
     over the values in P, assigns values to its weights
     and biases, and plots the resulting classification line.
 
       net = newp(minmax(p),1);
       net.iw{1,1} = [-1.2 -0.5];
       net.b{1} = 1;
       plotpc(net.iw{1,1},net.b{1})

 

我们把这个程序改一下

P=[0 1 0 1 1;1 1 1 0 0]
T=[0 1 0 0 0]
net = newp(minmax(P),1)

plotpv(P,T)

hold on


matlab-神经网络-感知器(2)
 

生成1个神经元的感知器,其中P是输入向量,T是目标函数

>> net.b{1}

ans =

     0

>> net.iw{1,1}

ans =

     0     0

>>

 

>> plotpc(net.iw{1,1},net.b{1})

此时执行没有意义,因为权值和阈值初始化为0

 

我们指定一个正确的权值和阈值

net.b{1}=-2

net.iw{1,1} =[1 1]

 plotpc(net.iw{1,1},net.b{1})

注意plotpc必须要在plotpv函数后执行,可以看到分界线正确显示出来

凡在分界线左侧的都是反例,右侧的是正例,即输出值>0
matlab-神经网络-感知器(2)
 

matlab-神经网络-感知器(2)


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论