forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sparse_dense.h
41 lines (27 loc) · 1.79 KB
/
sparse_dense.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
embodied in the content of this file are licensed under the BSD
(revised) open source license
*/
#ifndef SPARSE_DENSE_VECTOR_H
#define SPARSE_DENSE_VECTOR_H
#include <math.h>
#include "parse_example.h"
inline float sign(float w){ if (w < 0.) return -1.; else return 1.;}
inline float trunc_weight(float w, float gravity){
return (gravity < fabsf(w)) ? w - sign(w) * gravity : 0.;
}
float sd_add(weight* weights, size_t mask, feature* begin, feature* end);
float sd_add_trunc(weight* weights, size_t mask, feature* begin, feature* end, float gravity);
float sd_offset_add(weight* weights, size_t mask, feature* begin, feature* end, size_t offset);
void sd_offset_update(weight* weights, size_t mask, feature* begin, feature* end, size_t offset, float update, float regularization);
void quadratic(v_array<feature> &f, const v_array<feature> &first_part,
const v_array<feature> &second_part, size_t thread_mask);
float one_of_quad_predict(v_array<feature> &page_features, feature& offer_feature, weight* weights, size_t mask);
float one_pf_quad_predict(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask);
float one_pf_quad_predict_trunc(weight* weights, feature& f, v_array<feature> &cross_features, size_t mask, float gravity);
float offset_quad_predict(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask, size_t offset);
void print_audit_quad(weight* weights, audit_data& page_feature, v_array<audit_data> &offer_features, size_t mask);
void print_quad(weight* weights, feature& page_feature, v_array<feature> &offer_features, size_t mask);
float single_quad_weight(weight* weights, feature& page_feature, feature* offer_feature, size_t mask);
#endif