1 2 3 4 5 6 7 8 |
clear all; p1={-1 0 1 0 1 1 -1 0 -1 1 0 1}; t1={-1 -1 1 1 1 2 0 -1 -1 0 1 1}; net=linearlayer([0 1],0.1) %创建一个线性层,输入范围为【-1,1】,0和1的输入延迟,学习率为0.1 [net,y,e,pf]=adapt(net,p1,t1); mse(e); |
输出: ans = 0.7006 linea […]
1 2 3 4 5 6 7 |
clear all; p=[0 1 2 3 4 5]; t=[0 0 0 1 1 1]; net=feedforwardnet(3,'trainb'); %三个神经元,用trainb算法来算 net=train(net,p,t); y=net(p); plot(p,t,'o',p,y,'X'); |
注释1: 关于feedforwardnet训 […]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
clear all; x=[0 1 2 3 4 5 6 7 8]; t=[0 0.84 0.91 0.14 -0.77 -0.96 -0.28 0.66 0.99]; plot(x,t,'o'); net=feedforwardnet(10); %创建两层前反馈网络,有10元 net=configure(net,x,t); y1=net(x) plot(x,t,'o',x,y1,'x'); %%此时的y1: = -1.8260 -0.1460 1.5486 2.1347 3.5209 4.6727 4.3351 3.4458 4.0257 net=train(net,x,t); %对网络进行训练 y2=net(x); plot(x,t,'o',x,y1,'x',x,y2,'*'); %%此时的y2: -0.5608 0.8365 -0.3636 0.1337 -0.7477 -0.9427 -0.3031 0.6589 0.9676 |
实现了一个二维向量的感知网络:
1 2 3 4 5 6 7 8 9 10 |
clear all; net=newp([-2,2;-2,2],1); net.IW{1,1}=[-1,1] net.b{1}=[1]; p1=[1;1]; a1=sim(net,p1); p2=[1;-1]; a2=sim(net,p2); p3={[1;1],[1;-1]}; a3=sim(net,p3); |
对应输出为: […]