forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gd.h
77 lines (55 loc) · 2.16 KB
/
gd.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
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 GD_H
#define GD_H
#include <math.h>
#include "example.h"
#include "parse_regressor.h"
#include "parser.h"
#include "allreduce.h"
void print_result(int f, float res, v_array<char> tag);
struct gd_vars
{
float power_t;
gd_vars()
{};
void init()
{
power_t = 0.;
}
};
struct gd_thread_params
{
gd_vars* vars;
size_t thread_num;
regressor reg;
std::string* final_regressor_name;
node_socks* socks;
};
void print_audit_features(regressor ®, example* ec, size_t offset);
float finalize_prediction(float ret);
void predict(regressor& r, example* ex, size_t thread_num, gd_vars& vars);
float inline_predict(regressor ®, example* &ec, size_t thread_num);
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 single_quad_weight(weight* weights, feature& page_feature, feature* offer_feature, size_t mask);
void inline_train(regressor ®, example* &ec, size_t thread_num, float update);
void quadratic(v_array<feature> &f, const v_array<feature> &first_part,
const v_array<feature> &second_part, size_t thread_mask);
void print_audit_features(regressor ®, example* ec);
void train(weight* weights, const v_array<feature> &features, float update);
void train_one_example(regressor& r, example* ex, size_t thread_num, gd_vars& vars);
void train_offset_example(regressor& r, example* ex, size_t thread_num, gd_vars& vars, size_t offset);
void compute_update(example* ec, gd_vars& vars);
void offset_train(regressor ®, example* &ec, size_t thread_num, float update, size_t offset);
void train_one_example_single_thread(regressor& r, example* ex, gd_vars& vars);
void setup_gd(gd_thread_params t);
void destroy_gd();
void output_and_account_example(example* ec);
void finish_example(example* ec);
bool command_example(example*, gd_thread_params*);
void sync_weights(regressor *reg);
#endif