SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatentSOSVM.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012 Viktor Gal
8  * Copyright (C) 2012 Viktor Gal
9  */
10 
13 
14 using namespace shogun;
15 
18 {
19  register_parameters();
20  m_so_solver=NULL;
21 }
22 
24  : CLinearLatentMachine(model, C)
25 {
26  register_parameters();
27  set_so_solver(so_solver);
28 }
29 
31 {
32  SG_UNREF(m_so_solver);
33 }
34 
36 {
37  return NULL;
38 }
39 
41 {
42  SG_REF(so);
43  SG_UNREF(m_so_solver);
44  m_so_solver = so;
45 }
46 
48 {
49  float64_t lambda = 1/m_C;
51  so->set_lambda(lambda);
52  so->train();
53 
54  /* copy the resulting w */
55  SGVector<float64_t> cur_w = so->get_w();
56  memcpy(w.vector, cur_w.vector, cur_w.vlen*sizeof(float64_t));
57 
58  /* get the primal objective value */
59  float64_t po = so->get_result().Fp;
60 
61  SG_UNREF(so);
62 
63  return po;
64 }
65 
66 void CLatentSOSVM::register_parameters()
67 {
68  m_parameters->add((CSGObject**)&m_so_solver, "so_solver", "Structured Output Solver.");
69 }
70 

SHOGUN Machine Learning Toolbox - Documentation