SHOGUN  v2.0.0
 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 }
21 
23  : CLinearLatentMachine(model, C)
24 {
25  register_parameters();
26  set_so_solver(so_solver);
27 }
28 
30 {
31  SG_UNREF(m_so_solver);
32 }
33 
35 {
36  return NULL;
37 }
38 
40 {
41  SG_UNREF(m_so_solver);
42  SG_REF(so);
43  m_so_solver = so;
44 }
45 
47 {
48  float64_t lambda = 1/m_C;
50  so->set_lambda(lambda);
51  so->train();
52 
53  /* copy the resulting w */
54  SGVector<float64_t> cur_w = so->get_w();
55  memcpy(w.vector, cur_w.vector, cur_w.vlen*sizeof(float64_t));
56 
57  /* get the primal objective value */
58  float64_t po = so->get_result().Fp;
59 
60  SG_UNREF(so);
61 
62  return po;
63 }
64 
65 void CLatentSOSVM::register_parameters()
66 {
67  m_parameters->add((CSGObject**)&m_so_solver, "so_solver", "Structured Output Solver.");
68 }
69 

SHOGUN Machine Learning Toolbox - Documentation