⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rbfninterpolation.m

📁 內涵模糊理論與類神經網路的程式碼...提供初學者做研究參考
💻 M
字号:
% ==========================================================
% 
%           Neural Networks A Classroom Approach
%                     Satish Kumar
%             Copyright Tata McGraw Hill, 2004
%
% MATLAB code that implements RBFN regularized interpolation    
%              Reference: Table 8.11;Page 322
%
% ==========================================================


testpts = 100;
testx = linspace(-2*pi, 2*pi, testpts);
testy = 2*sin(testx)  + testx;

Q = 10;
noise = 0.6;
sigma = 0.6;
x = linspace(-2*pi,2*pi,Q);
scatter = (2*rand(1,Q) - 1)*noise;
d = 2*sin(x) + scatter + x ;

lambda = 0;

for i = 1:Q
   for j = 1:Q
      phi(i,j) = exp(-(x(i)-x(j))^2/(2*sigma^2));
   end
end

Wreg = inv(phi + (lambda * eye(Q))) * d';

for k = 1:testpts
   for i = 1:Q
      phitest(k,i) = exp(-(testx(k)-x(i))^2/(2*sigma^2));
      phislope(k,i) = -exp(-(testx(k)-x(i))^2/(2*sigma^2)) * (testx(k)-x(i));
   end
   f(k) = phitest(k,:)*Wreg;
   slope(k) = (phislope(k,:)*Wreg/sigma^2)^2;
end

figure(1)
subplot(2,2,1)
hold on
plot(testx, testy,'b')
plot(x, d, 'r^');
plot(testx, f, 'k','LineWidth',2);
axis([-2*pi 2*pi -7 7]);
grid on
title('(a)');

subplot(2,2,3)
hold on
plot(testx, slope, 'r','LineWidth',2);
area(testx, slope);
axis([-2*pi 2*pi 0 35]);
grid on
title('(c)');

lambda = 0.5;
W_reg = inv(phi + (lambda * eye(Q))) * d';

for k=1:testpts
    f(k) = phitest(k,:)*W_reg;
   slope(k) = (phislope(k,:)*W_reg/sigma^2)^2;
end

subplot(2,2,2)
hold on
plot(testx, testy,'b')
plot(x, d, 'r^');
plot(testx, f, 'k','LineWidth',2);
axis([-2*pi 2*pi -7 7]);
grid on
title('(b)');

subplot(2,2,4)
hold on
plot(testx, slope, 'r','LineWidth',2);
area(testx, slope);
axis([-2*pi 2*pi 0 35]);
grid on
title('(d)');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -