感知器实验实验

更新时间:2024-01-30 04:16:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

智能信

息技术处理技术实验

学班学成指

生姓名 级 号 绩

XX 电信093 094012003XX

XXX

导教师

电气与信息工程学院 2013年1 月 5日

实验一 感知器实验

一、实验目的

(1)熟悉感知器网络及相关知识。 (2)熟悉matlab相关的知识。

(3)学会利用matlab实现感知器网络,并将输入样本线性划分。

二、实验要求

(1)复习人工智能神经网络中感知器网络的相关内容。 (2)掌握感知器网络的学习算法。 (3)利用matlab建立感知器网络。

三、内容及步骤

设计单一感知器神经元来解决一个简单的分类问题:将4个输入向量分为两类,其中两个输入向量对应的目标值为1,另两个对应的目标值为0。

主要程序程序如下: P=[-1 -0.5 0.3 -0.1 50; -0.5 0.5 -0.5 1.0 35]; T=[1 1 0 0 0]; plotpv(P,T); pause;

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

plotpv(P,T);

linehandle=plotpc(net.IW{1},net.b{1}); E=1;

net=init(net);

linehandle=plotpc(net.IW{1},net.b{1});

while(sse(E))

[net,Y,E]=adapt(net,P,T);

linehandle=plotpc(net.IW{1},net.b{1}); drawnow; end; pause; watchoff;

p=[0.7;1.2]; a=sim(net,p); plotpv(p,a);

ThePoint=findobj(gca,'type','line'); set(ThePoint,'Color','red'); hold on; plotpv(P,T);

plotpc(net.IW{1},net.b{1}); hold off;

disp('End of percept1'); End of percept1

四、实验结果

通过实验程序导入后,可得到以下结果:

按任意键!

再按任意键!

就得出了结果。

将上例的输入向量扩充为10组,将输入向量分为4类,即输入向量为:

P=[0.1 0.7 0.8 0.8 1.0 0.3 0.0 -0.3 -0.5 -1.5; 1.2 1.8 1.6 0.6 0.8 0.5 0.2 0.8 -1.5 -1.3] 输出向量为:

T=[1 1 1 0 0 1 1 1 0 0; 0 0 0 0 0 1 1 1 1 1] 输入向量可以改动 程序:

P=[0.1 0.7 0.8 0.8 1.0 0.3 0.0 -0.3 -0.5 -1.5; 1.2 1.8 1.6 0.6 0.8 0.5 0.2 0.8 -1.5 -1.3]; T=[1 1 1 0 0 1 1 1 0 0; 0 0 0 0 0 1 1 1 1 1]; plotpv(P,T);

net=newp([-1.5 1;-1.5 1],2); figure; watchon; cla;

plotpv(P,T);

linehandle=plotpc(net.IW{1},net.b{1}); E=1;

net=init(net);

linehandle=plotpc(net.IW{1},net.b{1}); while(sse(E))

[net,Y,E]=adapt(net,P,T);

linehandle=plotpc(net.IW{1},net.b{1},linehandle); drawnow; end;

watchoff; figure;

p=[1.7;-1.2]; a=sim(net,p); plotpv(p,a);

ThePoint=findobj(gca,'type','line'); set(ThePoint,'Color','red'); hold on; plotpv(P,T);

plotpc(net.IW{1},net.b{1}); hold off;

disp('End of percept2'); End of percept2 运行结果:

按任意键运行!

得出了结果。

当网络的输入样本中存在奇异样本时(即该样本向量相对其他所有样本向量特别大或特别小),此时网络训练时间将大大增加。

程序:

P=[-0.5 -0.5 0.3 -0.1 -40; -0.5 0.5 -0.5 1.0 50]; T=[1 1 0 0 1]; plotpv(P,T);

net=newp([-40 1; -1 50],1); pause; plotpv(P,T);

linehandle=plotpc(net.IW{1},net.b{1}); cla;

plotpv(P,T);

linehandle=plotpc(net.IW{1},net.b{1}); E=1;

net.adaptParam.passes=1 net=init(net);

linehandle=plotpc(net.IW{1},net.b{1});

while(sse(E))

[net,Y,E]=adapt(net,P,T);

linehandle=plotpc(net.IW{1},net.b{1},linehandle); drawnow;

end; pause;

p=[0.7;1.2]; a=sim(net,p); plotpv(p,a);

ThePoint=findobj(gca,'type','line'); set(ThePoint,'Color','red'); hold on; plotpv(P,T);

plotpc(net.IW{1},net.b{1}); hold off; pause;

axis([-2 2 -2 2]);

disp('End of percept3'); 运行:

按任意键!

按任意键!

按任意键!

得出了结果!

五、实验总结

本次实验通过对matlab的操作来完成一系列实验,来设置一个感知器网络,并从中了解其基本的算法。在程序开始编写的过程中,很容易出现某些小错误,而导致程序的结果图无法正常显示,而通过老师指导和检查中,能够顺利的完成此次实验。

本文来源:https://www.bwwdw.com/article/7e1w.html

Top