SHOGUN  v3.2.0
StructuredModel.h
浏览该文件的文档.
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 Fernando José Iglesias García
8  * Copyright (C) 2012 Fernando José Iglesias García
9  */
10 
11 #ifndef _STRUCTURED_MODEL__H__
12 #define _STRUCTURED_MODEL__H__
13 
14 #include <shogun/base/SGObject.h>
17 
18 #include <shogun/lib/common.h>
19 #include <shogun/lib/SGVector.h>
21 
22 namespace shogun
23 {
24 
25 #define IGNORE_IN_CLASSLIST
26 
37  TMultipleCPinfo(uint32_t from, uint32_t N) : m_from(from), m_N(N) { }
39  uint32_t m_from;
41  uint32_t m_N;
42 };
43 
44 class CStructuredModel;
45 
47 struct CResultSet : public CSGObject
48 {
50  CResultSet();
51 
53  virtual ~CResultSet();
54 
56  virtual const char* get_name() const;
57 
60 
63 
66 
70 
73 };
74 
86 {
87  public:
90 
96  CStructuredModel(CFeatures* features, CStructuredLabels* labels);
97 
99  virtual ~CStructuredModel();
100 
112  virtual void init_primal_opt(
113  float64_t regularization,
118 
123  virtual int32_t get_dim() const = 0;
124 
129  void set_labels(CStructuredLabels* labs);
130 
135  CStructuredLabels* get_labels();
136 
138  virtual CStructuredLabels* structured_labels_factory(int32_t num_labels=0);
139 
144  void set_features(CFeatures* feats);
145 
150  CFeatures* get_features();
151 
164  SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, int32_t lab_idx);
165 
178  virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y);
179 
193  virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true) = 0;
194 
202  float64_t delta_loss(int32_t ytrue_idx, CStructuredData* ypred);
203 
211  virtual float64_t delta_loss(CStructuredData* y1, CStructuredData* y2);
212 
214  virtual const char* get_name() const { return "StructuredModel"; }
215 
220  virtual void init_training();
221 
229  virtual bool check_training_setup() const;
230 
240  virtual int32_t get_num_aux() const;
241 
251  virtual int32_t get_num_aux_con() const;
252 
253  private:
255  void init();
256 
257  protected:
260 
263 
264 }; /* class CStructuredModel */
265 
266 } /* namespace shogun */
267 
268 #endif /* _STRUCTURED_MODEL__H__ */
SGVector< float64_t > psi_truth
Base class of the labels used in Structured Output (SO) problems
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:102
double float64_t
Definition: common.h:48
Class CStructuredModel that represents the application specific model and contains most of the applic...
CStructuredLabels * m_labels
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
virtual const char * get_name() const
TMultipleCPinfo(uint32_t from, uint32_t N)
The class Features is the base class of all feature objects.
Definition: Features.h:62
CStructuredData * argmax
SGVector< float64_t > psi_pred
#define IGNORE_IN_CLASSLIST
Base class of the components of StructuredLabels

SHOGUN Machine Learning Toolbox - Documentation