frogfish 发表于 2007-6-25 03:15

反馈型神经网络理论及MATLAB实现的几个程序

摘自:神经网络理论与MATLAB7实现

Elman网络设计
p1 = sin(1:20);
p2 = sin(1:20)*2;
t1 = ones(1,20);
t2 = ones(1,20)*2;
%产生训练样本p和t
p = ;
t = ;
Pseq = con2seq(p);
Tseq = con2seq(t);
R = 1; % 输入元素的数目为1
S2 = 1; % 输出层的神经元个数为1
S1 = 10; %中间层有10个神经元
net=newelm([-2,2],,{'tansig','purelin'});
%设定网络训练次数
net.trainParam.epochs=300;
net=train(net,Pseq,Tseq);
y=sim(net,Pseq);
figure;
plot(t5,cat(2,y{:}),t5,cat(2,Tseq{:}),'b--');
%利用新的信号来测试网络
p3 = sin(1:20)*1.6;
t3 = ones(1,20)*1.6;
p4 = sin(1:20)*1.2;
t4 = ones(1,20)*1.2;
%产生测试样本pg和tg
pg = ;
tg = ;
pgseq = con2seq(pg);
a = sim(net,pgseq);
figure;
plot(t5,cat(2,a{:}),t5,tg,'b--');

[ 本帖最后由 frogfish 于 2007-6-25 03:20 编辑 ]

frogfish 发表于 2007-6-25 03:16

P=[0.4413 0.4707 0.6953 0.8133 0.4379 0.4677 0.6981 0.8002 0.4517 0.4725 0.7006 0.8201;
0.4379 0.4677 0.6981 0.8002 0.4517 0.4725 0.7006 0.8201 0.4557 0.4790 0.7019 0.8211;
0.4517 0.4725 0.7006 0.8201 0.4557 0.4790 0.7019 0.8211 0.4601 0.4811 0.7101 0.8298;]'
T=[0.4557 0.4790 0.7019 0.8211;
0.4601 0.4811 0.7101 0.8298;
0.4612 0.4845 0.7188 0.8312]';
threshold=;
a=;
for i=1:3
    net=newelm(threshold,,{'tansig','purelin'});
    net.trainParam.epochs=1000;
    net=init(net);
    net=train(net,P,T);
    y=sim(net,p_test);
    error(i,:)=y'-t;
end
hold off;
plot(1:4,error(1,:));
hold on;
plot(1:4,error(2,:),'-.');
hold on;
plot(1:4,error(3,:),'--');
hold off;

frogfish 发表于 2007-6-25 03:16

one=[-1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1-1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1];
two=;
T=';
net=newhop(T);
no2={'};
tu2=sim(net,{1,5},{},no2);
tu2{3}'

frogfish 发表于 2007-6-25 03:16

function c=bsb(x,beta,multi)

% function c=bsb(x,beta)
%
%This m-file duplicates the Brain State in a Box Experiment.
%    x   - input vector
%    beta- feedback factor
%    c   - number of iterations required for convergence
%   
% Hugh Pasika 1997

hold on
flag=0;   x=x(:);   c=2; %c is a general purpose counter
W=[.035 -.005; -.005 .035];

set(gca,'YLim',[-1 1]);      set(gca,'XLim',[-1 1])    % set axes

plot(x(1),x(2),'ob')         % plot first point   
orig=x';
plot(,,'-');      plot(,,'-')   % plot center lines
set(gca,'YTick',[-11 ]);   set(gca,'XTick',[-11 ])% label plot

while flag < 1,
y=x+beta*W*x;
x=(y(:,:) < -1 )*(-1) + (y(:,:)>1) + (y(:,:) > -1 & y(:,:) < 1).*y;
u(c,:)=x';
c=c+1;
if u(c-1,:) == u(c-2,:),
   flag=10;
   c=c-3;
end
end
u=u(2:c+1,:);
orig
plot(, ,'-b')
plot(u(:,1), u(:,2),'ob')
plot(u(:,1), u(:,2),'-b')
drawnow
fprintf(1,'It took %g iteration for a stable point to be reached.\n\n',c);
set(gca,'Box','on')
hold off

adiko 发表于 2007-7-1 13:22

谢谢~~:loveliness:

冬冬星LWWL 发表于 2009-3-17 20:34

楼主辛苦:handshake

zhuxiaoxun 发表于 2009-3-18 22:29

请问第一个程序的t5变量在哪定义的?

leei8210 发表于 2009-3-29 16:59

谢谢了!楼主辛苦了!

deepedlver 发表于 2009-5-12 16:57

原帖由 zhuxiaoxun 于 2009-3-18 22:29 发表 http://www.chinavib.com/forum/images/common/back.gif
请问第一个程序的t5变量在哪定义的?


同问,新学的不太明白

锦在熙 发表于 2012-7-30 11:38

为什么该程序一运行就显示“??? Error using ==> feedback at 72
Not enough input arguments. ”
页: [1]
查看完整版本: 反馈型神经网络理论及MATLAB实现的几个程序