声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2291|回复: 6

[综合讨论] W=+w 前后的w和W有什么区别

[复制链接]
发表于 2007-5-19 22:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
如题,谢谢
回复
分享到:

使用道具 举报

发表于 2007-5-19 23:07 | 显示全部楼层
w不变,W和w相等了
这个和C不一样,   W=+w,  matlab当成
W =0+w;
 楼主| 发表于 2007-5-19 23:22 | 显示全部楼层
好象没这么简单吧,为什么我看一个源程序,里面反复用到了行如这个格式的式子,如果是相等,那如W=+w,就可以直接调用w就可,但往往是变换后调用W,为什么呢,不解,呵呵,请指教下吧
发表于 2007-5-19 23:35 | 显示全部楼层
原帖由 juan_242 于 2007-5-19 23:22 发表
好象没这么简单吧,为什么我看一个源程序,里面反复用到了行如这个格式的式子,如果是相等,那如W=+w,就可以直接调用w就可,但往往是变换后调用W,为什么呢,不解,呵呵,请指教下吧


建议不要使用这些莫名其妙的语句
发表于 2007-5-20 00:24 | 显示全部楼层
可以发个程序上来看看,我用的7.0的,好像试验的结果就是这样的
 楼主| 发表于 2007-5-20 08:56 | 显示全部楼层

一个SVDD源程序,

%SVDD Support Vector Data Description
%
%       W = MYSVDD(A,FRACREJ,SIGMA)
%
% Optimizes a support vector data description for the dataset A by  quadratic programming. The data description uses the Gaussian       kernel by default. FRACREJ gives the fraction of the target set which will be rejected, when supplied FRACERR gives (an upper bound)    for the fraction of data which is completely outside the description.
% versions. This is to make the use of consistent_occ.m possible.
% Further note: this classifier is one of the few which can actually deal with example outlier objects!
%
% Default:  FRACREJ=0.05; SIGMA=5  (dangerous!)
%
function W = mysvdd(a,fracrej,sigma)

% First set up the parameters
if nargin < 3
        sigma = [];
end
if nargin < 2 | isempty(fracrej), fracrej = 0.05; end
if nargin < 1 | isempty(a) % empty svdd
        W = mapping(mfilename,{fracrej,sigma});
        W = setname(W,'Support vector data description');
        return
end

if isempty(sigma),
        sigma = 5;
end

if ~ismapping(fracrej) % training

        if isempty(sigma)
                error('This versions needs a sigma.');
        end
        % introduce outlier label for outlier class if it is available.
        if isocset(a)
                signlab = getoclab(a);
                if all(signlab<0), error('SVDD needs target objects!'); end
        else
                %error('SVDD needs a one-class dataset.');
      % Noo, be nice, everything is target:
      signlab = ones(size(a,1),1);
                %a = target_class(+a);
        end
        % check the rejection rates
        if (length(fracrej)<2) % if no bound on the outlier error is given, we
                                                                 % do not care
                fracrej(2) = 1;
        end
        if (fracrej(1)>1)
                warning('Fracrej > 1? I cannot reject more than all my target data!');
        end
        % Setup the appropriate C's
        nrtar = length(find(signlab==1));
        nrout = length(find(signlab==-1));
        warning off; % we could get divide by zero, but that is ok.
        C(1) = 1/(nrtar*fracrej(1));
        C(2) = 1/(nrout*fracrej(2));
        warning on;

        % Find the alpha's
        matver = version;
        % Standard optimization procedure:
        [alf,R2,Dx,J] = svdd_optrbf(sigma,+a,signlab,C);
        SVx = +a(J,:);
        alf = alf(J);
        % Compute the offset (not important, but now gives the possibility to
        % interpret the output as the distance to the center of the sphere)
        offs = 1 + sum(sum((alf*alf').*exp(-sqeucldistm(SVx,SVx)/(sigma*sigma)),2));

        % store the results
        W.j=J;
    W.s = sigma;
        W.a = alf;
        W.threshold = offs+R2;
        W.sv = SVx;
        W.offs = offs;
        W = mapping(mfilename,'trained',W,str2mat('target','outlier'),size(a,2),2);
        W = setname(W,'Support vector data description');
else                               %testing

        W = getdata(fracrej);
        m = size(a,1);

        % check if alpha's are OK
        if isempty(W.a)
                warning('The SVDD is empty or not well defined');
                out = zeros(m,1);
        end

        % and here we go:
        K = exp(-sqeucldistm(+a,W.sv)/(W.s*W.s));
        out = W.offs - 2*sum( repmat(W.a',m,1).* K, 2);
        newout = [out repmat(W.threshold,m,1)];

        % Store the distance as output:
        W = setdat(a,-newout,fracrej);
        W = setfeatdom(W,{[-inf 0] [-inf 0]});
end
return
发表于 2007-5-20 09:41 | 显示全部楼层
:@L 看不懂这个语句什么意思了
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-18 17:50 , Processed in 0.061530 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表