SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
Abstract class CLatentModel It represents the application specific model and contains most of the app...
Definition: LatentModel.h:33
Class DualLibQPBMSOSVM that uses Bundle Methods for Regularized Risk Minimization algorithms for stru...
Parameter * m_parameters
Definition: SGObject.h:505
#define SG_REF(x)
Definition: SGObject.h:51
void add(bool *param, const char *name, const char *description="")
Definition: Parameter.cpp:37
index_t vlen
Definition: SGVector.h:494
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
double float64_t
Definition: common.h:50
SGVector< float64_t > w
virtual CLatentLabels * apply_latent()
Definition: LatentSOSVM.cpp:35
void set_lambda(float64_t _lambda)
#define SG_UNREF(x)
Definition: SGObject.h:52
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
abstract implementaion of Linear Machine with latent variable This is the base implementation of all ...
void set_so_solver(CLinearStructuredOutputMachine *so)
Definition: LatentSOSVM.cpp:40
virtual bool train(CFeatures *data=NULL)
Definition: Machine.cpp:47
abstract class for latent labels As latent labels always depends on the given application, this class only defines the API that the user has to implement for latent labels.
Definition: LatentLabels.h:26
virtual float64_t do_inner_loop(float64_t cooling_eps)
Definition: LatentSOSVM.cpp:47

SHOGUN Machine Learning Toolbox - Documentation