Advertisement
Guest User

Untitled

a guest
Oct 19th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <eigen3/Eigen/Dense>
  2. #include <vector>
  3. #include <limits>
  4. #include <algorithm>
  5.  
  6. using Eigen::Matrix;
  7. using Eigen::Dynamic;
  8. using std::numeric_limits;
  9. using std::random_shuffle;
  10. using std::vector;
  11. using std::pair;
  12.  
  13. template<typename DataType, typename LabelType, class RandomAccessIterator,
  14. class DotCallback, class AddCallback>
  15. int liblinear_cs_train(RandomAccessIterator first, RandomAccessIterator last)
  16. {
  17. typedef Matrix<DataType,Dynamic,1> VectorXt;
  18. typedef vector<unsigned int> ActiveSet;
  19.  
  20. unsigned int iteration = 0;
  21. unsigned int n_iteration = 10;
  22. unsigned int n_classes = 2;
  23. unsigned int n_vectors = 3;
  24. unsigned int n_features = 2;
  25.  
  26. ActiveSet active_set;
  27. unsigned int active_set_size;
  28.  
  29. VectorXt QD(last-first);
  30. for (unsigned int i=0; first!=last; ++first)
  31. {
  32. QD[i] = DotCallback(*first);
  33. }
  34.  
  35. VectorXt G(n_classes);
  36.  
  37. while (iteration < n_iteration)
  38. {
  39. double stopping = - numeric_limits<double>::min();
  40.  
  41. random_shuffle(active_set.begin(),active_set.begin()+active_set_size);
  42.  
  43. for (ActiveSet::const_iterator iterator=active_set.begin();
  44. iterator!=active_set.end(); ++iterator)
  45. {
  46. unsigned int i = (*iterator);
  47. double Ai = QD[i];
  48.  
  49. if (Ai > 0)
  50. {
  51. }
  52. }
  53.  
  54. ++iteration;
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement