SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LinearStructuredOutputMachine.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) 2013 Thoralf Klein
8  * Written (W) 2012 Fernando José Iglesias García
9  * Copyright (C) 2012 Fernando José Iglesias García
10  */
11 
14 
15 using namespace shogun;
16 
19 {
20  register_parameters();
21 }
22 
24  CStructuredModel* model,
25  CStructuredLabels* labs)
26 : CStructuredOutputMachine(model, labs)
27 {
28  register_parameters();
29 }
30 
32 {
33 }
34 
36 {
37  m_w = w;
38 }
39 
41 {
42  return m_w;
43 }
44 
46 {
47  if (data)
48  {
49  set_features(data);
50  }
51 
52  CFeatures* model_features = this->get_features();
53  if (!model_features)
54  {
56  }
57 
58  int num_input_vectors = model_features->get_num_vectors();
59  CStructuredLabels* out;
60  out = m_model->structured_labels_factory(num_input_vectors);
61 
62  for ( int32_t i = 0 ; i < num_input_vectors ; ++i )
63  {
64  CResultSet* result = m_model->argmax(m_w, i, false);
65  out->add_label(result->argmax);
66 
67  SG_UNREF(result);
68  }
69  SG_UNREF(model_features);
70  return out;
71 }
72 
73 void CLinearStructuredOutputMachine::register_parameters()
74 {
75  SG_ADD(&m_w, "m_w", "Weight vector", MS_NOT_AVAILABLE);
76 }
77 
79 {
80 }
Base class of the labels used in Structured Output (SO) problems.
virtual int32_t get_num_vectors() const =0
virtual CStructuredLabels * apply_structured(CFeatures *data=NULL)
virtual CStructuredLabels * structured_labels_factory(int32_t num_labels=0)
Class CStructuredModel that represents the application specific model and contains most of the applic...
#define SG_UNREF(x)
Definition: SGObject.h:52
virtual void add_label(CStructuredData *label)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual CResultSet * argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training=true)=0
The class Features is the base class of all feature objects.
Definition: Features.h:68
CStructuredData * argmax
#define SG_ADD(...)
Definition: SGObject.h:81

SHOGUN Machine Learning Toolbox - Documentation