-
大小: 7KB文件類型: .rar金幣: 2下載: 1 次發(fā)布日期: 2021-04-17
- 語言: Matlab
- 標(biāo)簽: SVDD??數(shù)據(jù)??高斯支持??MATLAB??
資源簡介
高斯核支持向量數(shù)據(jù)描述(SVDD)方法的源碼
代碼片段和文件信息
function?[K]?=?kernel(kerxy)
%?Calculate?kernel?function.???
%?x:?輸入樣本n1×d的矩陣n1為樣本個(gè)數(shù)d為樣本維數(shù)
%?y:?輸入樣本n2×d的矩陣n2為樣本個(gè)數(shù)d為樣本維數(shù)
%?ker??核參數(shù)(結(jié)構(gòu)體變量)
%?the?following?fields:
%???type???-?linear?:??k(xy)?=?x‘*y
%????????????poly???:??k(xy)?=?(x‘*y+c)^d
%????????????gauss??:??k(xy)?=?exp(-0.5*(norm(x-y)/s)^2)??
%????????????????????????????????????????%?norm命令計(jì)算矩陣或向量(x-y)的2-范數(shù)
%????????????tanh???:??k(xy)?=?tanh(g*x‘*y+c)
%???degree?-?Degree?d?of?polynomial?kernel?(positive?scalar).
%???offset?-?Offset?c?of?polynomial?and?tanh?kernel?(scalar?negative?for?tanh).
%???width??-?Width?s?of?Gauss?kernel?(positive?scalar).
%???gamma??-?Slope?g?of?the?tanh?kernel?(positive?scalar).
%?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:?輸出核參數(shù)n1×n2的矩陣
%-------------------------------------------------------------%
switch?ker.type
????case?‘linear‘
????????K?=?x*y‘;?????????%?n*n的矩陣
????case?‘poly‘
????????d?=?ker.degree;
????????c?=?ker.offset;
????????K?=?(x*y‘+c).^d;
????case?‘gauss‘
????????s?=?ker.width;
????????rows?=?size(x1);
????????cols?=?size(y1);???
%?????????K=zeros(rowscols);
%?????????for?i?=?1:rows
%?????????????for?j?=?1:cols
%?????????????????tmp?=?norm(x(i:)-y(j:));
%?????????????????K(ij)?=?exp(-(tmp^2)/(s^2));
%?????????????end
%?????????end
??????tmp?=?zeros(rowscols);????????
????????for?i?=?1:rows
????????????for?j?=?1:cols
????????????????tmp(ij)?=?norm(x(i:)-y(j:));
???????????????
????????????end
????????end
?????K?=?exp(-(tmp.^2)/(s.^2));????
????case?‘tanh‘
????????g?=?ker.gamma;
????????c?=?ker.offset;
????????K?=?tanh(g*x*y‘+c);
????otherwise
????????K?=?0;
end
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1871??2013-04-01?22:23??exp15_svdd\kernel.m
?????文件???????4030??2013-04-06?14:00??exp15_svdd\sample_banana_200.mat
?????文件???????1337??2013-05-10?16:35??exp15_svdd\svddSim.m
?????文件???????1701??2013-04-02?11:52??exp15_svdd\svddTrain.m
?????文件???????1277??2014-05-24?09:14??exp15_svdd\svdd_banana_gauss.m
?????文件?????????18??2014-05-24?10:03??exp15_svdd\說明.txt
?????目錄??????????0??2014-05-24?10:03??exp15_svdd
-----------?---------??----------?-----??----
????????????????10234????????????????????7
評(píng)論
共有 條評(píng)論