SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 }

SHOGUN Machine Learning Toolbox - Documentation