SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
classifier
vw
vw_math.cpp
浏览该文件的文档.
1
/*
2
* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3
* embodied in the content of this file are licensed under the BSD
4
* (revised) open source license.
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Adaptation of Vowpal Wabbit v5.1.
12
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
13
*/
14
15
#include <
shogun/classifier/vw/vw_math.h
>
16
17
namespace
shogun
18
{
19
20
float32_t
sd_offset_add
(
float32_t
* weights,
vw_size_t
mask,
VwFeature
* begin,
VwFeature
* end,
vw_size_t
offset)
21
{
22
float32_t
ret = 0.;
23
for
(
VwFeature
* f = begin; f!= end; f++)
24
ret += weights[(f->weight_index + offset) & mask] * f->x;
25
return
ret;
26
}
27
28
float32_t
sd_offset_truncadd
(
float32_t
* weights,
vw_size_t
mask,
VwFeature
* begin,
VwFeature
* end,
vw_size_t
offset,
float32_t
gravity)
29
{
30
float32_t
ret = 0.;
31
for
(
VwFeature
* f = begin; f!= end; f++)
32
{
33
float32_t
w = weights[(f->weight_index+offset) & mask];
34
float32_t
wprime =
real_weight
(w,gravity);
35
ret += wprime*f->x;
36
}
37
return
ret;
38
}
39
40
float32_t
one_pf_quad_predict
(
float32_t
* weights,
VwFeature
& f,
v_array<VwFeature>
&cross_features,
vw_size_t
mask)
41
{
42
vw_size_t
halfhash =
quadratic_constant
* f.
weight_index
;
43
44
return
f.
x
*
45
sd_offset_add
(weights, mask, cross_features.
begin
, cross_features.
end
, halfhash);
46
}
47
48
float32_t
one_pf_quad_predict_trunc
(
float32_t
* weights,
VwFeature
& f,
v_array<VwFeature>
&cross_features,
vw_size_t
mask,
float32_t
gravity)
49
{
50
vw_size_t
halfhash =
quadratic_constant
* f.
weight_index
;
51
52
return
f.
x
*
53
sd_offset_truncadd
(weights, mask, cross_features.
begin
, cross_features.
end
, halfhash, gravity);
54
}
55
56
}
SHOGUN
机器学习工具包 - 项目文档