Genetic Optimization RBF Radial Basis Function MATLAB programming
Genetic Optimization • RBF (Radial Basis Function) • MATLAB programming Adavanced Numerical Computation 2008, AM NDHU 1
Example my_fun 2. m Adavanced Numerical Computation 2008, AM NDHU 2
Figure plot_myfun 2. m Adavanced Numerical Computation 2008, AM NDHU 3
[x_min fval] = ga(@my_fun 2, 2); x_min fval my_fun 2(x_min) hold on; plot 3(x_min(1), x_min(2), fval, 'ok'); Adavanced Numerical Computation 2008, AM NDHU 4
Learning RBF l Derive an objective function l Apply GA optimization to minimize the objective function Adavanced Numerical Computation 2008, AM NDHU 5
Requirement appoximate y[t] by y(t| ) exp exp . . x[t] Adavanced Numerical Computation 2008, AM NDHU 6
RBF Network function Adavanced Numerical Computation 2008, AM NDHU 7
Data Structure Adavanced Numerical Computation 2008, AM NDHU 8
Matlab functions l Net 2 x l x 2 Net l eva. RBF l myfun Adavanced Numerical Computation 2008, AM NDHU 9
Net 2 x l Input: Net l Translate an RBF Net to a vector Net 2 x. m Adavanced Numerical Computation 2008, AM NDHU 10
x 2 Net l Input : x l Translate x to an RBF Net x 2 Net. m Adavanced Numerical Computation 2008, AM NDHU 11
eva. RBF l Evaluate an RBF Net eva. RBF. m Adavanced Numerical Computation 2008, AM NDHU 12
Example: A random RBF mapping M=2; d=2; theta 2=rand(1, M*d+2*M+1); Net 2=x 2 Net(theta 2); figure x 1=-range: 0. 02: range; x 2=x 1; for i=1: length(x 1) x_test = [x 1(i)*ones(1, length(x 2)); x 2]; y_test=fx(x_test(1, : ), x_test(2, : )); xx=x_test'; [yhat, D]=eva. RBF(xx, Net 2); C(i, : )=yhat*max_y; end mesh(x 1, x 2, C); Adavanced Numerical Computation 2008, AM NDHU 13
Sampling paired data for training fstr=input('input a 2 D function: ', 's'); fx=inline(fstr); range=2*pi; x 1=-range: 0. 02: range; x 2=x 1; for i=1: length(x 1) C(i, : )=fx(x 1(i), x 2); end mesh(x 1, x 2, C); hold on; N=input('keyin sample size: '); x(1, : )=rand(1, N)*2*range-range; x(2, : )=rand(1, N)*2*range-range; n=rand(1, N)*0. 1 -0. 05; y=fx(x(1, : ), x(2, : ))+n; plot 3(x(2, : ), x(1, : ), y, '. '); Adavanced Numerical Computation 2008, AM NDHU 14
MSE( Mean Square Error) Objective function l Mean approximating error l Adavanced Numerical Computation 2008, AM NDHU 15
Objective function my_fun. m Adavanced Numerical Computation 2008, AM NDHU 16
GA optimization for RBF learning global tx global ty global max_y % run : sampling paired data tx=x; ty=y; max_y=max(y); M=3; d=2; L=M*d+2*M+1; [theta 2 fval] = ga(@my_fun, L); fval z = my_fun(theta 2); fprintf('ms training error derived by GA: %fn', z); Net 2=x 2 Net(theta 2); % Plot RBF mapping Adavanced Numerical Computation 2008, AM NDHU 17
- Slides: 17