声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2522|回复: 5

[综合讨论] [求助]小波神经网络编程

[复制链接]
发表于 2006-4-27 15:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
MATLAB最新的版本中也没有小波神经网络的源代码,是不是因为其小波函数太多了,不好分类编?小波神经网络已经应用的很广泛了啊!

[ 本帖最后由 ericlin 于 2006-8-10 16:10 编辑 ]
回复
分享到:

使用道具 举报

发表于 2006-4-28 09:49 | 显示全部楼层

回复:(ericlin)[求助]小波神经网络编程

clear all
%initiate of data
P=3 %numberof sample
m=1%number of input node
n=10%number of hidden node
N=1%number of ouptut node
%
%a(n) b(n) scale and shifting parameter matrix
%x(P,m) input matrix of P sample
%net(P,n) ouput of hidden node
%y(P,N) output of network
%d(P,N) ideal output of network
% phi(P,n) ouput of hidden node wavelet funciton
%W(N,n)weight value between ouput and hidden
%WW(n,m) weight value between hidden and input node
x=[4;5;6]; d=[1.3;3.6;6.7]; W=rand(N,n); WW=rand(n,m);a=ones(1,n);
for j=1:n, b(j)=j*P/n; end
%%%%%%%%%%%%%%%%%%
%EW(N,n) gradient of W
%EWW(n,m) gradient of WW
%Ea(n) gradient of a
%Eb(n) gradient of b
%%%%%%%%%%%%%%]
epoch=1; epo=100; error=0.05; err=0.01; delta =1; lin=0.5;
while (error>=err & epoch<=epo)

u=0;%u is the middle variant
%caculation of net input
for p=1:),  for j=1:n   % something wrong! By ChaChing
   u=0;
   for k=1:m, u=u+WW(j,k)*x(p,k); end
   net(p,j)=u;
end; end
%calculation of morlet 0r mexican wavelet output
for p=1:), for j=1:n  % something wrong! By ChaChing
   u=net(p,j); u=(u-b(j))/a(j);
   phi(p,j)=cos(1.75*u)*exp(-u*u/2); %morlet wavelet
   %phi(p,j)=(1-u^2)*exp(-u*u/2); %mexican hat wavelet
end; end
%calculation of output of network

for p=1:), for i=1:N  % something wrong! By ChaChing
   u=0;
   for j=1:n, u=u+W(i,j)*phi(p,j); end
   y(p,i)=delta*abs(u);
end; end
%calculation of error of output
u=0;
for p=1:P, for i=1:N
   u=u+abs(d(p,i)*log(y(p,i))+(1-d(p,i)*log(1-y(p,i))));
   %u=u+(d(p,i)-y(p,i))^2;
end; end
%u=u/2
error=u;
%calculate of gradient of network
for i=1:N, for j=1:n
   u=0;
   for p=1:P, u=u+(d(p,i)-y(p,i))*phi(p,j); end
   EW(i,j)=u;
   %EW(i,j)=-u;%the resule would be wrong
end; end
for j=1:n, for k=1:m
   u=0
   for p=1:P, for i=1:N
      u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)*x(p,k)/a(j) ;
   end; end
   EWW(j,k)=u;
   %EWW(j,k)=u the result would be wrong
end; end
for j=1:n, u=0
   for p=1:P, for i=1:N
       u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)/a(j) ;
   end; end
   Eb(j)=u;
end
for j=1:n, u=0
   for p=1:P, for i=1:N
      u=u+(d(p,i)-y(p,i))*W(i,j)*phi(p,j)*((net(p,j)-b(j))/b(j))/a(j) ;
   end; end
   Ea(j)=u;
end
%adjust of weight value
WW=WW-lin*EWW; W=W-lin*EW; a=a-lin*Ea; b=b-lin*Eb;
%number of epoch increase by 1
epoch=epoch+1;

end

[ 本帖最后由 ChaChing 于 2010-4-24 21:48 编辑 ]

评分

1

查看全部评分

 楼主| 发表于 2006-5-16 16:52 | 显示全部楼层
<P>哇,多谢happy大侠啊,好像有很多行啊,我要好好学才行啊。</P>
 楼主| 发表于 2006-8-10 15:54 | 显示全部楼层
我想能不能直接在原代码的基础上改动啊,比如说,将sigmiod的表达式改成小波morlet函数,再改其他相应的地方,不过小波函数还有平移因子和伸缩因子,但原代码中只有对应的一个阈值。

另外,假如有一个4-9-1的BP网络,那么是不是输入层和隐含层之间有一个9×4的权值矩阵(inputWeights=net.IW{1,1}),隐含层和输出层之间有一个1×9的权值矩阵(layerWeights=net.LW{2,1}),然后隐含层有一个含9个元素的阈值向量(inputbias=net.b{1}),输出层有一个含1个元素的阈值向量(layerbias=net.b{2}),这些值都应该是在网络创建newff是就已经随机赋值的吧?随机赋值的范围是多少啊?输入层有没有阈值啊?

[ 本帖最后由 ericlin 于 2006-8-10 16:46 编辑 ]
发表于 2006-10-10 21:47 | 显示全部楼层
这好像就一个网络训练过程吧?怎么用来预测呢?
小弟是新手,请多多包涵!
发表于 2010-4-24 21:51 | 显示全部楼层

回复 沙发 happy 的帖子

整理老帖, 发现2F Happy教授给的程序, 有些文字输入问题!?
个人不懂小波神经网络, 希望教授或高手更正之!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 22:41 , Processed in 0.062590 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表