SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
features
HashedDenseFeatures.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 Evangelos Anagnostopoulos
8
* Copyright (C) 2013 Evangelos Anagnostopoulos
9
*/
10
11
#ifndef _HASHED_DENSEFEATURES_H__
12
#define _HASHED_DENSEFEATURES_H__
13
14
#include <
shogun/features/DenseFeatures.h
>
15
#include <
shogun/features/DotFeatures.h
>
16
17
namespace
shogun
18
{
19
template
<
class
ST>
class
CDenseFeatures;
20
class
CDotFeatures;
21
25
template
<
class
ST>
class
CHashedDenseFeatures
:
public
CDotFeatures
26
{
27
public
:
28
35
CHashedDenseFeatures
(int32_t size=0,
bool
use_quadr =
false
,
bool
keep_lin_terms =
true
);
36
44
CHashedDenseFeatures
(
CDenseFeatures<ST>
* feats, int32_t d,
bool
use_quadr =
false
,
45
bool
keep_lin_terms =
true
);
46
54
CHashedDenseFeatures
(
SGMatrix<ST>
matrix, int32_t dm,
bool
use_quadr =
false
,
55
bool
keep_lin_terms =
true
);
56
66
CHashedDenseFeatures
(ST* src, int32_t num_feat, int32_t num_vec, int32_t d,
67
bool
use_quadr =
false
,
bool
keep_lin_terms =
true
);
68
76
CHashedDenseFeatures
(
CFile
* loader, int32_t d,
bool
use_quadr =
false
,
77
bool
keep_lin_terms =
false
);
78
80
CHashedDenseFeatures
(
const
CHashedDenseFeatures
& orig);
81
83
virtual
CFeatures
*
duplicate
()
const
;
84
86
virtual
~CHashedDenseFeatures
();
87
95
virtual
int32_t
get_dim_feature_space
()
const
;
96
106
virtual
float64_t
dot
(int32_t vec_idx1,
CDotFeatures
* df,
107
int32_t vec_idx2);
108
117
virtual
float64_t
dense_dot
(int32_t vec_idx1,
const
float64_t
* vec2,
118
int32_t vec2_len);
119
130
virtual
void
add_to_dense_vec
(
float64_t
alpha, int32_t vec_idx1,
131
float64_t
* vec2, int32_t vec2_len,
bool
abs_val =
false
);
132
138
virtual
int32_t
get_nnz_features_for_vector
(int32_t num);
139
151
virtual
void
*
get_feature_iterator
(int32_t vector_index);
152
165
virtual
bool
get_next_feature
(int32_t& index,
float64_t
& value,
166
void
* iterator);
167
173
virtual
void
free_feature_iterator
(
void
* iterator);
174
176
virtual
const
char
*
get_name
()
const
;
177
182
virtual
EFeatureType
get_feature_type
()
const
;
183
188
virtual
EFeatureClass
get_feature_class
()
const
;
189
194
virtual
int32_t
get_num_vectors
()
const
;
195
201
SGSparseVector<ST>
get_hashed_feature_vector
(int32_t vec_idx);
202
211
static
SGSparseVector<ST>
hash_vector
(
SGVector<ST>
vec, int32_t
dim
,
bool
use_quadratic
=
false
,
212
bool
keep_linear_terms
=
true
);
213
214
private
:
215
void
init(
CDenseFeatures<ST>
* feats, int32_t d,
bool
use_quadr,
bool
keep_lin_terms);
216
217
protected
:
218
220
CDenseFeatures<ST>
*
dense_feats
;
221
223
int32_t
dim
;
224
226
bool
use_quadratic
;
227
229
bool
keep_linear_terms
;
230
};
231
}
232
233
#endif // _HASHED_DENSEFEATURES_H__
SHOGUN
机器学习工具包 - 项目文档