ex1d2.m

来自「新的神经网络算法源程序」· M 代码 · 共 57 行

M
57
字号
%==============================================================%    Ex1d2: An example for using WaveNet,  1-D Interpolation%==============================================================% By Qinghua Zhang. March, 1994.help ex1d2echo on% The training data%===================% Input patternsx = (-1:.05:1)';% Output patternsy = (-2.186 * x - 1.2864) .* (x < -0.2) ...    + 4.246 * x             .* ((x >= -0.2) & (x < 0)) ...    + (exp(-0.5 .* x - 0.5) .* sin((3 .* x + 7) .* x)) .* (x > 0);% The data are depicted in the graphics window.clf; plot(x,y,'o'); xlabel('x'); ylabel('y'); title('The data to be interpolated');% We are going to use a WaveNet to interpolate the data.% You may set the number of wavelets in the network to 9% or choose it on-line with the aid of the FPE criterion.% Call the training procedure%=============================Key = keymenu('Make your choice','Use 9 wavelets','On-line choice');if Key==1  th = wnetreg(y, x, 9, 4, 3, 1, 5);   % Use 9 wavelets, 4 iterations, initialization mode 3,  % minimum number of covered data points 1, scanned levels 5.else  th = wnetreg(y, x, [], 4, 3, 1, 5); end% Examine the result of the interpolation%=========================================% Evaluate the network on a finer x-sequencexg = (-1:.01:1)';yg = wavenet(xg, th);plot(x,y,'o', xg,yg); xlabel('x'); ylabel('y');% The result of the interpolation is ploted in the graphics window.echo off

⌨️ 快捷键说明

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