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

📄 fsvmkernel.m

📁 些程序是对多类分类的另一种处理方法
💻 M
字号:
function K=fsvmkernel(ker,x,y)
%
%x       :输入向量
%ker   :核参数(结构体变量)
%ker=struct(
%         'poly' 线性核函数,'polyhomog' 多项式核函数,'gaussian' 高斯核函数等
% ker = struct('type','linear');
% ker = struct('type','ploy','degree',d,'offset',c);
% ker = struct('type','gauss','width',s);
% ker = struct('type','tanh','gamma',g,'offset',c);
%K 输出核参数;

options = optimset;
options.LargeScale = 'off';
options.Display = 'off';
ker.degree=2;
ker.offset=0;
 
switch ker.type
    case  'linear'
        K=x*y';
    case  'ploy'
        d=ker.degree;
        c=ker.offset;
        K=(x*y'+c).^d;
    case 'gauss'
        s=ker.wihth;
        rows=size(x,1);
        cols=size(y,1);
        tmp=zeros(rows,cols);
        for i=1:rows
            for j=1:cols
                tmp(i,j)=norm(x(:,i)-y(:,j));
            end
        end
        K=exp(-0.5*(tmp/s).^2);
    case 'tanh'
        g=ker.gamma;
        c=ker.offset;
        K=tanh(g*x*y'+c);
    otherwise
        k=0;
end

        
            
        
        
    
    

⌨️ 快捷键说明

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