function xiabo3;
%step 1=========================
%定义输入样本;
x=[0.3241 0.157 0.258 0.3801 0.3921;
0.4006 0.1885 0.3138 0.3353 0.3009;
0.3994 0.165 0.2476 0.2559 0.2798;
0.4262 0.1531 0.3183 0.2865 0.3695;
0.3693 0.156 0.2906 0.3379 0.3283;
0.4805 0.134 0.2488 0.3372 0.3476;
0.3079 0.1486 0.2681 0.366 0.3923;
0.414 0.1457 0.2783 0.2918 0.2774;
0.3996 0.1563 0.2508 0.3231 0.3326;
0.3759 0.1584 0.3096 0.2874 0.3677;];
targ=[0.0177 0.0354 0.0531 0.0708 0.0885 0.1062 0.1239 0.1357 0.0826 0.0295];
eta=0.02;aerfa=0.935;
%初始化连接权wjh(输出层和隐层的连接权);whi(隐层和输出层的连接权);
%假设小波函数节点数为:H个;样本数为P;
%输出节点数为:J个;输入节点数为:I个;
H=10;P=10;
I=5;
J=H;
%初始化小波参数
b=rand(H,1);
a=rand(H,1);
%初始化权系数;
whi=rand(I,H);
wjh=rand(H,J);
%阈值初始化;
b1=rand(H,1);
b2=rand(J,1);
p=0;
%保存的误差;
Err_NetOut=[];
flag=1;count=0;
while flag>0
flag=0;
count=count+1;
%step 2=================================
xhp1=0;
for h=1:H
for i=1:I
xhp1=xhp1+whi(i,h)*x(i);
end
ixhp(h)=xhp1+b1(h);
xhp1=0;
end
for h=1:H
oxhp(h)=fai((ixhp(h)-b(h))/a(h));
end
%step 3====================================
ixjp1=0;
for j=1:J
for h=1:H
ixjp1=ixjp1+wjh(h,j)*oxhp(h);
end
ixjp(j)=ixjp1+b2(j);
ixjp1=0;
end
for i=1:J
oxjp(i)=fnn(ixjp(i));
end
%step 6==保存每次误差=====
wuchayy=1/2*sumsqr(oxjp-targ);
%E_x=1/2*sumsqr(x);
Err_NetOut=[Err_NetOut wuchayy];%保存每次的误差;
%Err_rate=Err_NetOut/E_x;
%Err_rate
%oxjp
%求detaj ,detab2==================================
for j=1:J
detaj(j)=-(oxjp(j)-targ(j))*oxjp(j)*(1-oxjp(j));
end
for j=1:J
for h=1:H
detawjh(h,j)=eta*detaj(j)*oxhp(h);
end
end
detab2=eta*detaj;
%求detah, detawhi detab1 detab detaa;========================
sum=0;
for h=1:H
for j=1:J
sum=detaj(j)*wjh(h,j)*diffai((ixhp(h)-b(h))/a(h))/a(h)+sum;
end
detah(h)=sum;
sum=0;
end
for h=1:H
for i=1:I
detawhi(i,h)=eta*detah(h)*x(i);
end
end
detab1=eta*detah;
detab=-eta*detah;
for h=1:H
detaa(h)=-eta*detah(h)*((ixhp(h)-b(h))/a(h));
end
%引入动量因子aerfa,修正各个系数==========================================
wjh=wjh+(1+aerfa)*detawjh;
whi=whi+(1+aerfa)*detawhi;
a=a+(1+aerfa)*detaa';
b=b+(1+aerfa)*detab';
b1=b1+(1+aerfa)*detab1';
b2=b2+(1+aerfa)*detab2';
%======================================================
%引入修正算法!!
%判断所有的样本是否计算完==================================
p=p+1;
if p~=P
flag=flag+1;
else
if Err_NetOut(end)>0.01
flag=flag+1;
else
figure;
plot(Err_NetOut);
title('误差曲线');
disp('目标达到');
disp(oxjp);
end
end
if count>500
figure;
plot(Err_NetOut);
title('误差曲线');
disp('故障点距离');
disp(oxjp);
break;
end
end
%这里还需要定义三个函数
%代码:
function y3=diffai(x);
y3=-0.75*sin(1.75*x)*exp(-x.^2/2)-cos(1.75*x)*exp(-x.^2/2)*x;
%代码:
function yl=fai(x)
yl=cos(0.75.*x)+exp(-x.^2/2);
%代码:
function y2=fnn(x)
y2=1/(1+exp(-x));
xia_bo.rar_predict_xia_bo_小波 预测_小波神经网络_小波预测
版权申诉
40 浏览量
2022-09-22
19:42:28
上传
评论
收藏 1KB RAR 举报
寒泊
- 粉丝: 75
- 资源: 1万+
最新资源
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
- python-leetcode面试题解之第166题分数到小数-题解.zip
- python-leetcode面试题解之第165比较版本号-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈