📄 initializegnn_static.m
字号:
function [W]=initializegnn_static(m,n,N_h,overlapfactor)
%[W]=initializegnn_static(m,n,N_h)
%this initializes a static Generalized Neural Network using something like
%the Nguyen Widrow method [1]
%m=number of inputs (including a 1 for bias)
%n=number of outputs
%N_h=number of hidden neurons
%this is for bipolar activation functions
%
%Reference:
%Nguyen, D. and Widrow, B. "Improving the Learning Speed of 2-Layer
%Neural Networks By Choosing Initial Values for the Adaptive Weights",
%Proceedings of the International Joint Conference on Neural Networks, San
%Diego, pp. 21-26, 1990.
% Copyright Travis Wiens 2008
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% If you would like to request a commerical (or other) license, please
% feel free to contact travis.mlfx@nutaksas.com
if nargin<4
overlapfactor=0.7;%how much neurons overlap
end
W=zeros(n+m+N_h);
for i=1+m:(n+m+N_h)
%use Nguyen Widrow
N_inputs=i-2;%inputs to neuron (except 1)
W_temp=2*rand(1,N_inputs)-1;%random direction (note this is biased away from axes)
W_mag=overlapfactor*((n+m+N_h)/2)^(1/N_inputs);%magnitude of weight vector
W_temp=W_mag/(sqrt(sum(W_temp.^2)))*W_temp;%scale direction to magnitude
W(i,1:m-1)=W_temp(1:m-1);%skip over x=1 at m
W(i,m+1:N_inputs+1)=W_temp(m:end);
W(i,m)=(2*rand-1)*W_mag;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -