Changeset 1672


Ignore:
Timestamp:
Dec 22, 2008, 2:27:20 PM (15 years ago)
Author:
Peter
Message:

refs #470: svm_test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/svm_test.cc

    r1487 r1672  
    9292  }
    9393
     94  // tol defined on learning precision
    9495  double tol=1e-6;
    95   if (std::abs(classifier2.alpha()(1)-2)>tol ||
    96       std::abs(classifier2.alpha()(2)-2)>tol){
     96  if (!suite.equal_fix(classifier2.alpha()(1), 2.0, tol) ||
     97      !suite.equal_fix(classifier2.alpha()(2), 2.0, tol) ) {
    9798    suite.err() << "wrong alpha" << std::endl;
    9899    suite.err() << "alpha: " << classifier2.alpha() <<  std::endl;
     
    129130     
    130131  // Comparing alpha to alpha_matlab
    131   theplu::yat::utility::Vector diff_alpha(alpha);
    132   diff_alpha-=alpha_matlab;
    133   if (!(diff_alpha*diff_alpha<1e-10) ){
     132  if (!suite.equal_range_fix(alpha.begin(), alpha.end(),
     133                             alpha_matlab.begin(), 1e-6) ) {
    134134    suite.err() << "Difference to matlab alphas too large\n";
    135135    suite.add(false);
    136136  }
     137
    137138
    138139  // Comparing output to target
     
    142143    if (output(i)*target(i) < 1){
    143144      if (target.binary(i))
    144         slack += 1 - output(i);
     145        slack = 1 - output(i);
    145146      else
    146         slack += 1 + output(i);
     147        slack = 1 + output(i);
     148      double slack_bound=2e-7;
     149      if (slack > slack_bound || std::isnan(slack)){
     150        suite.err() << "Slack too large. Is the bias correct?\n";
     151        suite.err() << "slack: " << slack << std::endl;
     152        suite.err() << "expected less than " << slack_bound << std::endl;
     153        suite.add(false);
     154      }
    147155    }
    148   }
    149   double slack_bound=2e-7;
    150   if (slack > slack_bound || std::isnan(slack)){
    151     suite.err() << "Slack too large. Is the bias correct?\n";
    152     suite.err() << "slack: " << slack << std::endl;
    153     suite.err() << "expected less than " << slack_bound << std::endl;
    154     suite.add(false);
    155156  }
    156157 
Note: See TracChangeset for help on using the changeset viewer.