ica.m
来自「Simon Haykin的 《Neural NetWorks》例子原码」· M 代码 · 共 70 行
M
70 行
% The time period of the signal consideredTf=0.5; % The sampling time periodTs=1e-5;t=0:Ts:Tf;Num_iter=100000;% The source signalsu1=0.1*sin(400*t).*cos(30*t);u2=0.01*sign(sin(500*t+9*cos(40*t)));u3=2*rand(1,length(t))-1;u=[u1; u2; u3];A=[0.56 0.79 -0.37; -0.75 0.65 0.86; 0.17 0.32 -0.48];% Mixing the sourcesx=A*u;% Runs the Algorithm for 10 different initial weightsfor r=1:10,flag=0;% error definition for convergenceerror=1e-2;nu=0.1;% initialising the weightsW=0.1*rand(3,3);% storing the initial weightsW_init((r-1)*3+1:r*3,1:3)=W;for i=1:Num_iter,% Demixing x with W y=W*x;% The activation function f=(3/4)*y.^11+(25/4)*y.^9+(-14/3)*y.^7+(-47/4)*y.^5+(29/4)*y.^3; dW=(eye(3)-f*y')*W;% The weight update W=W+nu*dW% Break if Algorithm diverges if (sum(sum(isnan(W)))>0) flag=1; break; end max(max(abs(dW)));% Break if Algorithm converges-- max weight update is less than error if (max(max(abs(dW)))<error & i>10) break; end;end% Number of iterations takenif (~flag) num(r)=i; else num(r)=0; end% store the final weightsW_end((r-1)*3+1:r*3,1:3)=W;iend%save all valuessave NUM8 num -asciisave W_init8 W_init -ascii save W_end8 W_end -ascii
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?