SHOGUN
v3.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
18
#include <
shogun/lib/common.h
>
19
#include <
shogun/lib/SGVector.h
>
20
#include <
shogun/lib/StructuredData.h
>
21
22
namespace
shogun
23
{
24
25
#define IGNORE_IN_CLASSLIST
26
31
IGNORE_IN_CLASSLIST
struct
TMultipleCPinfo
{
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
59
CStructuredData
*
argmax
;
60
62
SGVector< float64_t >
psi_truth
;
63
65
SGVector< float64_t >
psi_pred
;
66
69
float64_t
score
;
70
72
float64_t
delta
;
73
};
74
85
class
CStructuredModel
:
public
CSGObject
86
{
87
public
:
89
CStructuredModel
();
90
96
CStructuredModel
(
CFeatures
* features,
CStructuredLabels
* labels);
97
99
virtual
~CStructuredModel
();
100
112
virtual
void
init_primal_opt
(
113
float64_t
regularization,
114
SGMatrix< float64_t >
& A,
SGVector< float64_t >
a,
115
SGMatrix< float64_t >
B,
SGVector< float64_t >
& b,
116
SGVector< float64_t >
lb,
SGVector< float64_t >
ub,
117
SGMatrix < float64_t >
& C);
118
123
virtual
int32_t
get_dim
()
const
= 0;
124
129
void
set_labels
(
CStructuredLabels
* labs);
130
135
CStructuredLabels
*
get_labels
();
136
141
void
set_features
(
CFeatures
* feats);
142
147
CFeatures
*
get_features
();
148
161
SGVector< float64_t >
get_joint_feature_vector
(int32_t feat_idx, int32_t lab_idx);
162
175
virtual
SGVector< float64_t >
get_joint_feature_vector
(int32_t feat_idx,
CStructuredData
* y);
176
190
virtual
CResultSet
*
argmax
(
SGVector< float64_t >
w, int32_t feat_idx,
bool
const
training =
true
) = 0;
191
199
float64_t
delta_loss
(int32_t ytrue_idx,
CStructuredData
* ypred);
200
208
virtual
float64_t
delta_loss
(
CStructuredData
* y1,
CStructuredData
* y2);
209
211
virtual
const
char
*
get_name
()
const
{
return
"StructuredModel"
; }
212
217
virtual
void
init_training
();
218
226
virtual
bool
check_training_setup
()
const
;
227
237
virtual
int32_t
get_num_aux
()
const
;
238
248
virtual
int32_t
get_num_aux_con
()
const
;
249
250
private
:
252
void
init();
253
254
protected
:
256
CStructuredLabels
*
m_labels
;
257
259
CFeatures
*
m_features
;
260
261
};
/* class CStructuredModel */
262
263
}
/* namespace shogun */
264
265
#endif
/* _STRUCTURED_MODEL__H__ */
SHOGUN
Machine Learning Toolbox - Documentation