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

📄 rbfdesign.m

📁 人工神经网络的源码编程
💻 M
字号:
function H = rbfDesign(X, C, R, options)% H = rbfDesign(X, C, R, options)%% Gets the design matrix from the input data, centre positions% and radii factors.%% Input%       X       Input training data (n-by-p)%       C       List of centres (n-by-m)%       R	Scale factors: scalar, n-vector, or n-by-n matrix%	opt	Specifying basis function type ('g' for Gaussian,%		'c' for Cauchy) and whether bias unit is rquired%		(if yes then 'b').%% Output%       H       Design matrix (p-by-m)% default function type% 'g' = gaussian (0)% 'c' = cauchy (1)% 'm' = multiquadric (2)% 'i' = inverse multiquadric (3)type = 0;% default biasbias = 0;% process optionsif nargin > 3	for option = options		if option == 'g'			type = 0;		elseif option == 'c'			type = 1;		elseif option == 'm'			type = 2;		elseif option == 'i'			type = 3;		elseif option == 'b'			bias = 1;		else			error('rbfDesign: illegal option')		end	endend% preliminary sizing[n, p] = size(X);[n1, m] = size(C);if n ~= n1	error('rbfDesign: mismatched X, C')end[rr, rc] = size(R);% determine scaling typeif rr == 1 & rc == 1	SCALING_TYPE = 1;	% same radius for each centreelseif rr == 1	if rc == n		SCALING_TYPE = 2;	% same diagonal metric for each centre		R = R';	elseif rc == m		SCALING_TYPE = 4;	% different radius for each centre		R = R';	else		error('rbfDesign: mismatched C and row vector R')	endelseif rc == 1	if rr == n		SCALING_TYPE = 2;	% same diagonal metric for each centre	elseif rr == m		SCALING_TYPE = 4;	% different radius for each centre	else		error('rbfDesign: mismatched C and row vector R')	endelseif rr == n	if rc == n		SCALING_TYPE = 3;	% same metric for each centre		IR = inv(R);	elseif rc == m		SCALING_TYPE = 5;	% different diagonal metric for each centre	else		error('rbfDesign: mismatched C and matrix R')	endelseif rc == n	if rr == m		SCALING_TYPE = 5;	% different diagonal metric for each centre		R = R';	else		error('rbfDesign: mismatched C and matrix R')	endelse	error('rbfDesign: wrong sized R')end% start constructing HH = zeros(p, m);for j = 1:m	% get p difference vectors for this centre	D = X - dupCol(C(:,j),p);	% do metric calculation	if SCALING_TYPE == 1		% same radius for each centre		s = diagProduct(D',D) / R^2;	elseif SCALING_TYPE == 2	% same diagonal metric for each centre		DR = D ./ dupCol(R, p);		s = diagProduct(DR',DR);	elseif SCALING_TYPE == 3	% same metric for each centre		DR = IR * D;		s = diagProduct(DR',DR);	elseif SCALING_TYPE == 4	% different radius for each centre		s = diagProduct(D',D) / R(j)^2;	else				% different diagonal metric for each centre		DR = D ./ dupCol(R(:,j), p);		s = diagProduct(DR',DR);	end	% apply basis function	if type == 0		% Gaussian (default)		h = exp(-s);	elseif type == 1	% Cauchy		h = 1 ./ (s + 1);	elseif type == 2	% multiquadric		h = sqrt(s + 1);	elseif type == 3        % inverse multiquadric		h = 1 ./ sqrt(s + 1);	end	% insert result in H	H(:, j) = h;end% add bias unitif bias	H = [H ones(p, 1)];end

⌨️ 快捷键说明

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