SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
structure
StructuredModel.h
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 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
>
15
#include <
shogun/features/Features.h
>
16
#include <
shogun/labels/StructuredLabels.h
>
17
#include <
shogun/lib/SGVector.h
>
18
#include <
shogun/lib/StructuredData.h
>
19
20
namespace
shogun
21
{
22
23
#define IGNORE_IN_CLASSLIST
24
29
IGNORE_IN_CLASSLIST
struct
TMultipleCPinfo
{
31
uint32_t
_from
;
33
uint32_t
N
;
34
};
35
36
class
CStructuredModel
;
37
39
struct
CResultSet
:
public
CSGObject
40
{
42
CResultSet
() :
CSGObject
(),
argmax
(NULL) { };
43
45
virtual
~CResultSet
() {
SG_UNREF
(
argmax
) }
46
48
CStructuredData
*
argmax
;
49
51
SGVector< float64_t >
psi_truth
;
52
54
SGVector< float64_t >
psi_pred
;
55
58
float64_t
score
;
59
61
float64_t
delta
;
62
64
virtual
const
char
*
get_name
()
const
{
return
"ResultSet"
; }
65
};
66
77
class
CStructuredModel
:
public
CSGObject
78
{
79
public
:
81
CStructuredModel
();
82
88
CStructuredModel
(
CFeatures
* features,
CStructuredLabels
* labels);
89
91
virtual
~CStructuredModel
();
92
103
virtual
void
init_opt
(
104
SGMatrix< float64_t >
& A,
SGVector< float64_t >
a,
105
SGMatrix< float64_t >
B,
SGVector< float64_t >
& b,
106
SGVector< float64_t >
lb,
SGVector< float64_t >
ub,
107
SGMatrix < float64_t >
& C);
108
113
virtual
int32_t
get_dim
()
const
= 0;
114
119
void
set_labels
(
CStructuredLabels
* labs);
120
125
CStructuredLabels
*
get_labels
();
126
131
void
set_features
(
CFeatures
* feats);
132
137
CFeatures
*
get_features
();
138
151
SGVector< float64_t >
get_joint_feature_vector
(int32_t feat_idx, int32_t lab_idx);
152
165
virtual
SGVector< float64_t >
get_joint_feature_vector
(int32_t feat_idx,
CStructuredData
* y);
166
180
virtual
CResultSet
*
argmax
(
SGVector< float64_t >
w, int32_t feat_idx,
bool
const
training =
true
) = 0;
181
189
float64_t
delta_loss
(int32_t ytrue_idx,
CStructuredData
* ypred);
190
198
virtual
float64_t
delta_loss
(
CStructuredData
* y1,
CStructuredData
* y2);
199
201
virtual
const
char
*
get_name
()
const
{
return
"StructuredModel"
; }
202
210
virtual
bool
check_training_setup
()
const
;
211
221
virtual
int32_t
get_num_aux
()
const
;
222
232
virtual
int32_t
get_num_aux_con
()
const
;
233
241
virtual
float64_t
risk
(
float64_t
* subgrad,
float64_t
* W,
TMultipleCPinfo
* info=0);
242
243
private
:
245
void
init();
246
247
protected
:
249
CStructuredLabels
*
m_labels
;
250
252
CFeatures
*
m_features
;
253
254
};
/* class CStructuredModel */
255
256
}
/* namespace shogun */
257
258
#endif
/* _STRUCTURED_MODEL__H__ */
SHOGUN
Machine Learning Toolbox - Documentation