• 大小: 2KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-18
  • 语言: Matlab
  • 标签: matlab  

资源简介

使用的是matlab软件,采用bp神经网络算法模拟逼近非线性sin函数的m文件

资源截图

代码片段和文件信息

inputNums=15; %??????
outputNums=15; %??????
hideNums=10; %?????
maxcount=10000; %??????
precision=0.01; %????
alpha=0.1; %???
% a=0.5; %?????
v=rand(inputNumshideNums); %?????????
% deltv=zeros(inputNumshideNums);
% dv=zeros(inputNumshideNums);
w=rand(hideNumsoutputNums); %?????????
% deltw=zeros(hideNumsoutputNums);
% dw=zeros(hideNumsoutputNums);
% v_start=v;
% w_start=w;
error=zeros(1outputNums);
in=-1:0.1:1;
expectout=sin(in+1); %????
count=1;

while (count<=maxcount)    %????
for i=1:inputNums          %?????
x(i)=in(i);
end
for k=1:outputNums
d(k)=expectout(k);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ???????
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for j=1:hideNums
out1=0;
for i=1:inputNums
out1=out1+x(i)*v(ij); %???????????x(i)v(ij)
end
y1(j)=1/(1+exp(-out1)); %??????f(x)=1/(1+exp(-x))???s??
end
for k=1:outputNums
out2=0;
for j=1:hideNums
out2=out2+y1(j)*w(jk); %???????????y1(j)w(jk)
end
output(k)=1/(1+exp(-out2)); %?????

end
%%%%%%%%%%%%%%%%%%%%%%% ??????棗???????LMS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
error=0;
for k=1:outputNums
error=error+(d(k)-output(k))^2;

评论

共有 条评论