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

📄 alphalms.m

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


% MATLAB PROGRAM FOR ALPHA LEAST MEAN SQUARED LEARNING
% One-dimensional input data

max_points = 200;						% Assume 200 data points
x = linspace(0,2.5,max_points);	% Generate the x linspace
y = .5*x + 0.333;						% Define a straight line
scatter = rand(1,max_points);		% Generate scatter vector
ep = .1;									% Compress scatter to 0.1
d = ((2*scatter-1)*ep) + y;		% Set up desired values

eta = .01;								% Set learning rate
w = 3*(2*rand(1,2) - 1);			% Randomize weights

for loop = 1:50						% Train for 50 epochs
    randindex = randperm(200);	% Randomize order
    for j = 1: max_points			% For each data points
        i = randindex(j);			% Get the index
        s(i) = w(1) + w(2)*x(i);	% Compute signal value
        err(i) = d(i) - s(i);		% Compute pattern error
        w(1) = w(1) + eta*err(i)/(1+x(i)^2); % Change the weights
        w(2) = w(2) + eta*err(i)*x(i)/(1+x(i)^2);
    end
end

s = w(1) + w(2)*x;  % Finally compute the function learnt
plot(x,s,'r');      % Plot the result

⌨️ 快捷键说明

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