亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? example43_run_a.m

?? 神經網絡VC++代碼 人工神經網絡原理及仿真實例.
?? M
?? 第 1 頁 / 共 5 頁
字號:
      while (param<=max(range)),
        paramSeq = [paramSeq param];
        param = param*abs(step);
      end
    end
    otherwise
      % Additive update for kernels other than 'rbf'
      if step==0,
        step = -1;
      end
      if step<0,
        paramSeq = max(range):step:min(range);
      else
        paramSeq = min(range):step:max(range);
      end
  end
end
  

% Storing all validation set errors for each parameter choice
allErr = zeros(nfold, length(paramSeq));
% Storing the confusion matrices for each parameter choice
cm = cell(1, length(paramSeq));
for j = 1:length(paramSeq),
  cm{j} = zeros(2);
end

% shuffle X and Y in the same way
perm = randperm(N);
X = X(perm,:);
Y = Y(perm,:);

% size of one test set
chsize = floor (N/nfold);
% the training set is not exactly the whole data minus the one test set,
% but it is the union of the other test sets. So only effsize examples
% of the data set will ever be used
effsize = nfold*chsize;

% check if leave-one-out CV (or almost such) is required
usePrev = (nfold>=(N/2));
prevInd = [];

for i = 1:nfold,
  % currentX/Y is the current training set
  if (nfold == 1),
    currentX = X;
    currentY = Y;
    testX = Xv;
    testY = Yv;
  else
    % start and end index of current test set
    ind1 = 1+(i-1)*chsize;
    ind2 = i*chsize;
    currentInd = [1:(ind1-1), (ind2+1):effsize];
    currentX = X(currentInd, :);
    currentY = Y(currentInd, :);
    testX = X(ind1:ind2,:);
    testY = Y(ind1:ind2,:);
  end;
  % We start out with the most powerful kernel (smallest sigma for RBF
  % kernel, highest degree for polynomial). We assume that all training
  % examples will be support vectors due to overfitting, thus we start
  % the optimization with a value of C/2 for each example.
  if length(net.c(:))==1,
    alpha0 = repmat(net.c, [length(currentY) 1]);
    % The same upper bound for all examples
  elseif length(net.c(:))==2,
    alpha0 = zeros([length(currentY) 1]);
    alpha0(currentY>0) = net.c(1);
    alpha0(currentY<=0) = net.c(2);
    % Different upper bounds C for the positive and negative examples
  else
    net2.c = net.c(perm);
    alpha0 = net2.c(currentInd);
    % Use different C for each example: permute the original C's
  end
  alpha0 = alpha0/2;
  % Start out with alpha = C/2 for the optimization routine.
  % another little trick for leave-one-out CV: training sets will only
  % slightly differ, thus use the alphas from the previous iteration,
  % even if it resulted from a different parameter setting, as initial
  % values alpha0
  if usePrev & ~isempty(prevInd),
    a = zeros(N, 1);
    a(currentInd) = alpha0;
    a(prevInd) = prevAlpha;
    alpha0 = a(currentInd);
  end
  
  % Now loop over all parameter settings and train the SVM on currentX/Y
  net2 = net;
  if (dodisplay>0),
    fprintf('Split %i of the training data:\n', i);
  end
  for j = 1:length(paramSeq),
    param = paramSeq(j);
    net2.kernelpar = param;
    % Plug the current parameter settings into the SVM and train on the
    % current training set
    net2 = svmtrain(net2, currentX, currentY, alpha0, max(0,dodisplay-2));
    % Evaluate on the non-training data
    testPred = svmfwd(net2, testX);
    allErr(i, j) = mean(testY ~= testPred);
    % Compute the confusion matrix
    for k = [1 2],
      for l = [1 2],
        c(k,l) = sum(((testPred>=0)==(l-1)).*((testY>=0)==(k-1)));
      end
    end
    cm{j} = cm{j}+c;
    % take out the computed coefficients alpha and use them as starting
    % values for the next iteration (next parameter choice)
    alpha0 = net2.alpha;
    if (dodisplay>1),
      fprintf('Split %i with parameter %g:\n', i, param);
      fprintf('  Test set error = %2.3f%%\n', allErr(i, j)*100);
      [fracSV, normW] = svmstat(net2, (dodisplay>2));
      fprintf('  Norm of the separating hyperplane: %g\n', normW);
      fprintf('  Fraction of support vectors: %2.3f%%\n', fracSV*100);
    end
  end
  if usePrev,
    prevAlpha = net2.alpha;
    prevInd = currentInd;
  end
end

% Compute mean and standard deviation over all nfold runs
meanErr = mean(allErr, 1);
stdErr = std(allErr, 0, 1);
CVErr = [meanErr; stdErr]';
% Find the point of minimum mean error and plug that parameter into the
% output SVM structure. If there should be several points of minimal
% error, select the one with minimal standard deviation
[sortedMean, sortedInd] = sort(meanErr);
minima = find(sortedMean(1)==meanErr);
[dummy, sortedInd2] = sort(stdErr(minima));
net.kernelpar = paramSeq(minima(sortedInd2(1)));

if (dodisplay>0),
  for j = 1:length(paramSeq),
    fprintf('kernelpar=%g: Avg CV error %2.3f%% with stddev %1.4f\n', ...
            paramSeq(j), meanErr(j)*100, stdErr(j)*100);
    if any(cm{j}~=0),
      fprintf('  Confusion matrix, averaged over all runs:\n');
      fprintf('                  Predicted class:\n');
      fprintf('               %5i         %5i\n', -1, +1);
      c1 = cm{j}';
      c2 = 100*c1./repmat(sum(c1), [2 1]);
      c3 = [c1(:) c2(:)]';
      fprintf(['  True -1: %5i (%3.2f%%)  %5i (%3.2f%%)\n  True +1: %5i' ...
               ' (%3.2f%%)  %5i (%3.2f%%)\n'], c3(:));
    end
  end
end


function [Y, Y1] = svmfwd(net, X)

% 

% Check arguments for consistency
errstring = consist(net, 'svm', X);
if ~isempty(errstring);
  error(errstring);
end
[N d] = size(X);
if strcmp(net.kernel, 'linear'),
  if ~isfield(net, 'normalw') | ~all(size(net.normalw)==[1 d]),
    error('Structure NET does not contain a valid field ''normalw''');
  end
else
  if ~isfield(net, 'sv') | ((size(net.sv, 2)~=d) & ~isempty(net.sv)),
    error('Structure NET does not contain a valid field ''sv''');
  end
  nbSV = size(net.sv, 1);
  if nbSV~=size(net.svcoeff, 1),
    error('Structure NET does not contain a valid field ''svcoeff''');
  end
  if ~isfield(net, 'bias') | ~all(size(net.bias)==[1 1]),
    error('Structure NET does not contain a valid field ''bias''');
  end
end

if strcmp(net.kernel, 'linear'),
  Y1 = X*(net.normalw');
else
  chsize = net.chunksize;
  Y1 = zeros(N, 1);
  chunks1 = ceil(N/chsize);
  chunks2 = ceil(nbSV/chsize);
  for ch1 = 1:chunks1,
    ind1 = (1+(ch1-1)*chsize):min(N, ch1*chsize);
    for ch2 = 1:chunks2,
      ind2 = (1+(ch2-1)*chsize):min(nbSV, ch2*chsize);
      K12 = svmkernel(net, X(ind1, :), net.sv(ind2, :));
      Y1(ind1) = Y1(ind1)+K12*net.svcoeff(ind2);
    end
  end
end
Y1 = Y1+net.bias;
Y = sign(Y1);
Y(Y==0) = 1;


function K = svmkernel(net, X1, X2)

% 

errstring = consist(net, 'svm', X1);
if ~isempty(errstring);
  error(errstring);
end
errstring = consist(net, 'svm', X2);
if ~isempty(errstring);
  error(errstring);
end
[N1, d] = size(X1);
[N2, d] = size(X2);

switch net.kernel
  case 'linear'
    K = X1*X2';
  case 'poly'
    K = (1+X1*X2').^net.kernelpar(1);
  case 'rbf'
    dist2 = repmat(sum((X1.^2)', 1), [N2 1])' + ...
            repmat(sum((X2.^2)',1), [N1 1]) - ...
            2*X1*(X2');
    K = exp(-dist2/(net.nin*net.kernelpar(1)));
  case 'rbffull'
    bias = 0;
    if any(all(repmat(size(net.kernelpar), [4 1]) == ...
               [d 1; 1 d; d+1 1; 1 d+1], 2), 1),
      weights = diag(net.kernelpar(1:d));
      if length(net.kernelpar)>d,
        bias = net.kernelpar(end);
      end
    elseif all(size(net.kernelpar)==[d d]),
      weights = net.kernelpar;
    else
      error('Size of NET.kernelpar does not match the chosen kernel ''rbffull''');
    end
    dist2 = (X1.^2)*weights*ones([d N2]) + ...
            ones([N1 d])*weights*(X2.^2)' - ...
            2*X1*weights*(X2');
    K = exp(bias-dist2/net.nin);
  otherwise
    error('Unknown kernel function');
end
K = double(K);
% Convert to full matrix if inputs are sparse

function [fracSV, normW, nbSV, nbBoundSV, posSV, negSV, posBound, negBound] = svmstat(net, doDisplay)

% 

if nargin<2,
  doDisplay = 0;
end

nbSV = 0;
fracSV = 0;
nbPosSV = 0;
nbNegSV = 0;
normW = 0;
if (net.nbexamples<=0) | (size(net.svcoeff,1)==0),
  warning('The given SVM has not been trained yet');
  return;
end

if isfield(net, 'use2norm'),
  use2norm = net.use2norm;
else
  use2norm = 0;
end


posSV = find(net.svcoeff>0);
negSV = find(net.svcoeff<0);
% Indices of the positive and negative examples that have become Support
% Vectors
nbPosSV = length(posSV);
nbNegSV = length(negSV);
nbSV = nbPosSV+nbNegSV;
fracSV = nbSV/net.nbexamples;
if (nargout<2) & ~doDisplay,
  % shortcut to avoid the expensive computation of the norm
  return;
end

% Extract the upper bound for the examples that are Support Vectors
if length(net.c(:))==1,
  C = repmat(net.c, [length(net.svcoeff) 1]);
  % The same upper bound for all examples
elseif length(net.c(:))==2,
  C = zeros([length(net.svcoeff) 1]);
  C(posSV) = net.c(1);
  C(negSV) = net.c(2);
  % Different upper bounds C for the positive and negative examples
else
  C = net.c(net.svind);
end

if isfield(net, 'alphatol'),
  tol = net.alphatol;
else
  tol = net.accur;
  % old versions of SVM used only one field NET.accur
end
if use2norm,
  posBound = [];
  negBound = [];
else  
  posBound = find(abs(net.svcoeff(posSV))>(C(posSV)-tol));
  negBound = find(abs(net.svcoeff(negSV))>(C(negSV)-tol));
end
nbPosBound = length(posBound);
nbNegBound = length(negBound);
nbBoundSV = nbPosBound+nbNegBound;

if strcmp(net.kernel, 'linear') & isfield(net, 'normalw'),
  normW = norm(net.normalw);
  % linear kernel: norm of the separating hyperplane can be computed
  % directly
else
  if use2norm,
    alpha = abs(net.svcoeff);
    % For the 2norm SVM, the norm of the hyperplance is easy to compute
    normW = sqrt(sum(alpha)+sum((alpha.^2)./C));
  else
    % normal 1norm SVM:
    [dummy, svOutput] = svmfwd(net, net.sv);
    svOutput = svOutput-net.bias;
    % norm of the hyperplane is computed using the output
    % of the SVM for all Support Vectors without the bias term
    normW = sqrt(net.svcoeff'*svOutput);
    % norm is basically the quadratic term of the SVM objective function
  end
end

if doDisplay,
  fprintf('Number of Support Vectors (SV): %i\n', nbSV);
  fprintf('  (that is a fraction of %2.3f%% of the training examples)\n', ...
	  100*fracSV);
  if ~use2norm,
    fprintf('  %i of the SV have a coefficient ALPHA at the upper bound\n', ...
            nbBoundSV);
  end
  fprintf('  %i Support Vectors from positive examples\n', nbPosSV);
  if ~use2norm,
    fprintf('     %i of them have a coefficient ALPHA at the upper bound\n', ...
            nbPosBound);
  end
  fprintf('  %i Support Vectors from negative examples\n', nbNegSV);
  if ~use2norm,
    fprintf('     %i of them have a coefficient ALPHA at the upper bound\n', ...
            nbNegBound);
  end
  fprintf('Norm of the separating hyperplane: %g\n', normW);
end

function [x,lb,ub,msg] = checkbounds(xin,lbin,ubin,nvars)


msg = [];
% Turn into column vectors
lb = lbin(:); 
ub = ubin(:); 
xin = xin(:);

lenlb = length(lb);
lenub = length(ub);
lenx = length(xin);

% Check maximum length
if lenlb > nvars
   warning('Length of lower bounds is > length(x); ignoring extra bounds');
   lb = lb(1:nvars);   
   lenlb = nvars;
elseif lenlb < nvars
   lb = [lb; -inf*ones(nvars-lenlb,1)];
   lenlb = nvars;
end

if lenub > nvars
   warning('Length of upper bounds is > length(x); ignoring extra bounds');
   ub = ub(1:nvars);
   lenub = nvars;
elseif lenub < nvars
   ub = [ub; inf*ones(nvars-lenub,1)];
   lenub = nvars;
end

% Check feasibility of bounds
len = min(lenlb,lenub);
if any( lb( (1:len)' ) > ub( (1:len)' ) )
   count = full(sum(lb>ub));
   if count == 1
      msg=sprintf(['\nExiting due to infeasibility:  %i lower bound exceeds the' ...
            ' corresponding upper bound.\n'],count);
   else

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美国产电影| 在线看不卡av| 亚洲一区在线观看免费观看电影高清| 7777女厕盗摄久久久| 91浏览器入口在线观看| 九色综合狠狠综合久久| 亚洲一区在线视频观看| 国产日韩高清在线| 67194成人在线观看| 不卡区在线中文字幕| 激情文学综合插| 中文字幕一区二区视频| 久久久久国产一区二区三区四区| 久久久亚洲精品石原莉奈| 欧美日韩国产bt| 日韩欧美国产成人一区二区| 欧美一区二区三区公司| 91麻豆自制传媒国产之光| 欧美一三区三区四区免费在线看| 91久久一区二区| 欧美成人一区二区| 欧美在线三级电影| 日韩精品每日更新| 久久这里只有精品6| 成人精品高清在线| 亚洲综合激情网| 日韩欧美综合一区| 99视频一区二区| 日韩精品午夜视频| 久久久久综合网| 欧美午夜精品理论片a级按摩| 蜜臀久久99精品久久久久久9| 国产精品网站一区| 欧美日韩视频在线第一区 | 欧美色手机在线观看| 另类专区欧美蜜桃臀第一页| 亚洲欧美综合另类在线卡通| 日韩一区二区精品葵司在线| av一区二区三区| 最新欧美精品一区二区三区| 成人a级免费电影| 欧美日韩一区二区在线观看 | 久久精品国产免费看久久精品| 欧美日韩国产成人在线免费| 日本在线不卡一区| 精品国产乱码久久久久久久| 国产精品系列在线播放| 91精品国产丝袜白色高跟鞋| 91久久精品一区二区三| 综合久久久久综合| 精品少妇一区二区三区免费观看 | 久久国产精品99久久久久久老狼 | 亚洲国产综合人成综合网站| 欧美日韩精品一区二区天天拍小说| 国产成人午夜电影网| 日韩高清中文字幕一区| 亚洲三级在线播放| 久久精品免费在线观看| 日韩一区二区三区在线观看 | 欧美在线高清视频| 99精品黄色片免费大全| 国产精品亚洲人在线观看| 麻豆一区二区在线| 日本色综合中文字幕| 亚洲国产日韩av| 亚洲一区二区在线视频| 亚洲精品v日韩精品| 亚洲欧洲日韩女同| 国产精品久久一卡二卡| 国产欧美日韩不卡免费| 国产亚洲人成网站| 久久夜色精品国产噜噜av| 日韩免费看的电影| 日韩一级精品视频在线观看| 91精品国产综合久久精品| 欧美日韩国产成人在线免费| 欧美人妖巨大在线| 欧美高清精品3d| 欧美久久久一区| 欧美一区2区视频在线观看| 欧美高清视频不卡网| 欧美日韩一区中文字幕| 欧美日韩国产高清一区二区三区 | 欧美www视频| 久久午夜国产精品| 国产亚洲短视频| 国产精品午夜电影| 亚洲色图欧美在线| 亚洲综合小说图片| 日本女人一区二区三区| 久久不见久久见免费视频7| 久久99九九99精品| 粉嫩在线一区二区三区视频| jlzzjlzz欧美大全| 在线看国产一区二区| 91精品国产综合久久婷婷香蕉| 日韩午夜在线观看| 国产欧美日本一区二区三区| 国产精品久久久久影视| 夜夜嗨av一区二区三区网页| 亚洲va国产天堂va久久en| 免费的成人av| 大桥未久av一区二区三区中文| 色综合久久综合中文综合网| 欧美区一区二区三区| 精品国产自在久精品国产| 国产精品看片你懂得| 亚洲国产毛片aaaaa无费看| 欧美aaa在线| 99在线精品观看| 欧美一级日韩免费不卡| 国产色91在线| 亚洲.国产.中文慕字在线| 国产一区二区在线免费观看| 9i在线看片成人免费| 欧美一区二区三区婷婷月色 | 国产精品成人免费在线| 亚洲综合男人的天堂| 精彩视频一区二区| 99久久免费精品高清特色大片| 91精品午夜视频| 国产精品二区一区二区aⅴ污介绍| 午夜av区久久| 不卡的av在线播放| 91精品国产91久久综合桃花| 国产精品久久久久9999吃药| 日本欧美一区二区在线观看| 成人精品免费看| 日韩视频免费直播| 亚洲激情男女视频| 国产精品一区二区在线观看网站| 欧洲国内综合视频| 国产精品无人区| 狠狠色狠狠色综合系列| 欧美日韩日本视频| 综合欧美亚洲日本| 国产99久久久国产精品潘金| 在线91免费看| 一区av在线播放| aaa欧美日韩| 国产欧美日韩在线| 韩国三级电影一区二区| 欧美人与性动xxxx| 一区二区三区日韩| 99国产欧美久久久精品| 欧美成人伊人久久综合网| 性感美女久久精品| 欧美羞羞免费网站| 亚洲精品久久久蜜桃| 东方aⅴ免费观看久久av| 精品成人一区二区三区四区| 亚洲第一久久影院| 欧美中文字幕久久| 亚洲免费伊人电影| 成人美女视频在线观看18| 久久网站最新地址| 精品在线播放免费| 日韩欧美国产一区二区三区 | 国产精品久久久爽爽爽麻豆色哟哟| 韩国理伦片一区二区三区在线播放| 欧美区在线观看| 天堂久久一区二区三区| 欧美午夜精品久久久久久超碰| 一区二区三区不卡视频在线观看 | 奇米精品一区二区三区四区 | 婷婷久久综合九色国产成人| 欧美性受极品xxxx喷水| 一区二区三区不卡视频| 欧洲另类一二三四区| 亚洲成人你懂的| 欧美日韩午夜在线| 奇米色一区二区| 精品国产青草久久久久福利| 激情都市一区二区| 中文一区二区在线观看| jlzzjlzz国产精品久久| 一卡二卡三卡日韩欧美| 91麻豆精品91久久久久同性| 奇米一区二区三区av| 久久久亚洲高清| 97久久久精品综合88久久| 亚洲欧美激情一区二区| 欧美色爱综合网| 奇米精品一区二区三区在线观看 | 91精品国产综合久久久久久久| 日产国产欧美视频一区精品| 日韩美女视频在线| 国产激情视频一区二区在线观看| 中文字幕+乱码+中文字幕一区| 91蜜桃婷婷狠狠久久综合9色| 一区二区三区国产豹纹内裤在线| 欧美最新大片在线看| 肉丝袜脚交视频一区二区| 欧美日韩高清在线播放| 国产乱一区二区| 国产精品精品国产色婷婷| 欧美日韩免费电影| 轻轻草成人在线| 久久伊99综合婷婷久久伊| jizzjizzjizz欧美|