SHOGUN
3.2.1
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
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
:
259
CStructuredLabels
*
m_labels
;
260
262
CFeatures
*
m_features
;
263
264
};
/* class CStructuredModel */
265
266
}
/* namespace shogun */
267
268
#endif
/* _STRUCTURED_MODEL__H__ */
SHOGUN
Machine Learning Toolbox - Documentation