SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
structure
FactorGraphModel.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) 2013 Shell Hu
8
* Copyright (C) 2013 Shell Hu
9
*/
10
11
#ifndef __FACTOR_GRAPH_MODEL_H__
12
#define __FACTOR_GRAPH_MODEL_H__
13
14
#include <
shogun/lib/SGString.h
>
15
#include <
shogun/lib/DynamicObjectArray.h
>
16
#include <
shogun/structure/StructuredModel.h
>
17
#include <
shogun/structure/FactorType.h
>
18
#include <
shogun/structure/MAPInference.h
>
19
20
namespace
shogun
21
{
22
30
class
CFactorGraphModel
:
public
CStructuredModel
31
{
32
public
:
34
CFactorGraphModel
();
35
44
CFactorGraphModel
(
CFeatures
* features,
CStructuredLabels
* labels,
45
EMAPInferType
inf_type =
TREE_MAX_PROD
,
bool
verbose =
false
);
46
48
~CFactorGraphModel
();
49
51
virtual
const
char
*
get_name
()
const
{
return
"FactorGraphModel"
; }
52
59
void
add_factor_type
(
CFactorType
* ftype);
60
65
void
del_factor_type
(
const
int32_t ftype_id);
66
68
CDynamicObjectArray
*
get_factor_types
()
const
;
69
74
CFactorType
*
get_factor_type
(
const
int32_t ftype_id)
const
;
75
77
SGVector<int32_t>
get_global_params_mapping
()
const
;
78
83
SGVector<int32_t>
get_params_mapping
(
const
int32_t ftype_id);
84
86
SGVector<float64_t>
fparams_to_w
();
87
92
void
w_to_fparams
(
SGVector<float64_t>
w);
93
106
virtual
SGVector< float64_t >
get_joint_feature_vector
(int32_t feat_idx,
CStructuredData
* y);
107
121
virtual
CResultSet
*
argmax
(
SGVector< float64_t >
w, int32_t feat_idx,
bool
const
training =
true
);
122
130
virtual
float64_t
delta_loss
(
CStructuredData
* y1,
CStructuredData
* y2);
131
136
virtual
void
init_training
();
137
149
virtual
void
init_primal_opt
(
150
float64_t
regularization,
151
SGMatrix< float64_t >
& A,
SGVector< float64_t >
a,
152
SGMatrix< float64_t >
B,
SGVector< float64_t >
& b,
153
SGVector< float64_t >
lb,
SGVector< float64_t >
ub,
154
SGMatrix < float64_t >
& C);
155
160
virtual
int32_t
get_dim
()
const
;
161
162
private
:
164
void
init();
165
166
protected
:
168
CDynamicObjectArray
*
m_factor_types
;
169
171
SGVector<int32_t>
m_w_map
;
172
174
SGVector<float64_t>
m_w_cache
;
175
177
EMAPInferType
m_inf_type
;
178
180
bool
m_verbose
;
181
};
182
183
}
184
185
#endif
186
SHOGUN
机器学习工具包 - 项目文档