自组织神经网络的实现
2015-07-28 10:54
603 查看
1、可以调用MATLAB工具箱里的函数创建竞争性神经网络: 主要进行分类:
newc(p,s,KLR,CLR) --------------------------------------p表示输入的范围,
s-------------------------------表示神经元的个数 KLR表示Kohonen学习速率,-------------------------------CLR表示Conscience的学习速率
该网络的训练:
2、自组织特征映射类型的神经网络
net=newsom(p,[d1 d2 .....],tfcn,dfcn,steps,in)
p表示输入向量,di表示第i层大小,,默认[5 8], tfcn表示网络的拓扑结构,默认的是hextop, dfcn表示网络的距离函数,默认的是linkdist
step表示调整阶段的邻域变为1的步骤,默认100, in表示初始网络的大小,默认3
SOFM网络的建立:
LVQ神经网络
主要用于模式分类:
netnewlvq(pr,sl,pc,ir,if)
pr表示R*2的矩阵,代表输入向量元素的最大值和最小值
s1表示隐含层的神经元数目;
pc为二元向量,表示典型的类别权重百分比;
ir表示学习速度
if学习函数
竞争性网络的一个分类:
自组织特征映射网络的实验:
LVQ神经网络的运用:分类:
newc(p,s,KLR,CLR) --------------------------------------p表示输入的范围,
s-------------------------------表示神经元的个数 KLR表示Kohonen学习速率,-------------------------------CLR表示Conscience的学习速率
<span style="font-size:18px;">p=[0.1 0.8 0.1 0.9;0.2 0.9 0.1 0.8]; net=newc([0 1;0 1],2); net.iw{1,1} net.b{1}</span>
该网络的训练:
<span style="font-size:18px;">p = [.1 .8 .1 .9; .2 .9 .1 .8] net = newc([0 1; 0 1],2); wts = net.IW{1,1} biases = net.b{1} net.trainFcn net.trainParam.epochs = 500; net = train(net,p); a = sim(net,p) ac = vec2ind(a)</span>
2、自组织特征映射类型的神经网络
net=newsom(p,[d1 d2 .....],tfcn,dfcn,steps,in)
p表示输入向量,di表示第i层大小,,默认[5 8], tfcn表示网络的拓扑结构,默认的是hextop, dfcn表示网络的距离函数,默认的是linkdist
step表示调整阶段的邻域变为1的步骤,默认100, in表示初始网络的大小,默认3
SOFM网络的建立:
<span style="font-size:18px;">net = newsom([0 2; 0 1],[2 3]); P = [.1 .3 1.2 1.1 1.8 1.7 .1 .3 1.2 1.1 1.8 1.7;... 0.2 0.1 0.3 0.1 0.3 0.2 1.8 1.8 1.9 1.9 1.7 1.8] plot(P(1,:),P(2,:),'o','markersize',8) hold on plotsom(net.iw{1,1},net.layers{1}.distances) hold off net.iw{1,1}</span>网络的训练:
<span style="font-size:18px;">net = newsom([0 2; 0 1],[2 3]); P = [.1 .3 1.2 1.1 1.8 1.7 .1 .3 1.2 1.1 1.8 1.7;... 0.2 0.1 0.3 0.1 0.3 0.2 1.8 1.8 1.9 1.9 1.7 1.8] plot(P(1,:),P(2,:),'o','markersize',8) hold on plotsom(net.iw{1,1},net.layers{1}.distances) hold off net.iw{1,1} net.trainParam.epochs = 1000; net = train(net,P); plotsom(net.iw{1,1},net.layers{1}.distances)</span>
LVQ神经网络
主要用于模式分类:
netnewlvq(pr,sl,pc,ir,if)
pr表示R*2的矩阵,代表输入向量元素的最大值和最小值
s1表示隐含层的神经元数目;
pc为二元向量,表示典型的类别权重百分比;
ir表示学习速度
if学习函数
<span style="font-size:18px;">P = [-3 -2 -2 0 0 0 0 2 2 3; 0 1 -1 2 1 -1 -2 1 -1 0], Tc = [1 1 1 2 2 2 2 1 1 1], plotvec(P,Tc,'*'), T = ind2vec(Tc);%稀疏矩阵 targets = full(T) %对稀疏矩阵进行填充 net = newlvq(P,4,[.6 .4]); %表示第二层的权值重60的对应着targets第一行的元素1,40对应着第二行元素1 net.IW{1,1} net.LW{2,1} Y = sim(net,P); Yc = vec2ind(Y) </span>
竞争性网络的一个分类:
<span style="font-size:18px;">X = [0 1; 0 1]; % 定义输入类别范围 clusters = 8; % 类别数目 points = 10; % 每一类中的样本数 std_dev = 0.05; % 每一类的标准差 P = nngenc(X,clusters,points,std_dev); %生成输入样本向量系列 plot(P(1,:),P(2,:),'+r'); title('Input Vectors'); xlabel('p(1)'); ylabel('p(2)'); net = newc([0 1;0 1],8,.1); w = net.IW{1}; plot(P(1,:),P(2,:),'+r'); hold on; circles = plot(w(:,1),w(:,2),'ob'); net.trainParam.epochs = 7; net = train(net,P); w = net.IW{1}; delete(circles); plot(w(:,1),w(:,2),'ob'); p = [0; 0.2]; a = sim(net,p) </span>
自组织特征映射网络的实验:
<span style="font-size:18px;">angles = 0:0.5*pi/99:0.5*pi; P = [sin(angles); cos(angles)]; plot(P(1,:),P(2,:),'+r') net = newsom([0 1;0 1],[10]); net.trainParam.epochs = 10; net = train(net,P); plotsom(net.iw{1,1},net.layers{1}.distances) p = [1;0]; a = sim(net,p) </span>
LVQ神经网络的运用:分类:
<span style="font-size:18px;">P = [-3 -2 -2 0 0 0 0 +2 +2 +3; 0 +1 -1 +2 +1 -1 -2 +1 -1 0]; C = [1 1 1 2 2 2 2 1 1 1]; T = ind2vec(C); cla for i=1:10 if(C(i)==1) plot(P(1,i),P(2,i),'+') hold on; else plot(P(1,i),P(2,i),'o') hold on; end end net = newlvq(minmax(P),4,[.6 .4],0.1); hold on W1 = net.IW{1}; plot(W1(1,1),W1(1,2),'*') title('Input/Weight Vectors'); xlabel('P(1), W(1)'); ylabel('P(2), W(3)'); net.trainParam.epochs=150; net=train(net,P,T); W1 = net.IW{1}; W2 = vec2ind(net.IW{1}); cla; for i=1:10 if(C(i)==1) plot(P(1,i),P(2,i),'+') hold on; else plot(P(1,i),P(2,i),'o') hold on; end end for i=1:4 if(W2(i)==1) plot(W1(i, 1),W1(i, 2),'*') hold on; else plot(W1(i, 1),W1(i, 2),'.') hold on; end end p = [0.2; 1]; a = vec2ind(sim(net,p)), </span>
相关文章推荐
- Nmap新增脚本http-svn-enum和http-svn-info
- Linux网络编程select模型的实现
- ProtoBuf
- https 对接非对称密钥加密 MD5及数字签名相关
- TCP and UDP Small Servers
- 【iOS】MD5加密与网络数据安全
- 网络请求之GET、POST请求
- http错误码
- https://123.56.95.148/svn/Source/secretary
- 7月第3周网络安全报告:应用程序漏洞居首 涨27.7%
- JAVA网络编程-----TCP沟通
- Java网络编程基础
- 大黄蜂(HORNET):比Tor更快更安全的匿名网络
- Source Insight基本使用和快捷键 http://www.cnblogs.com/mengdd/p/3506526.html
- SCVMM 2012 R2运维管理十四之:VMM中网络概述
- SCVMM 2012 R2运维管理十四之:VMM中网络概述
- poj 3469 dinic网络流模板
- 摘:MD231 gprs模块建立tcp或udp连接,AT命令详细参考
- tcp超时重传
- 看你的门-攻击服务器(4)-HTTP参数注入攻击