diff options
author | John Langford <jl@hunch.net> | 2013-03-20 06:26:14 +0400 |
---|---|---|
committer | John Langford <jl@hunch.net> | 2013-03-20 06:26:14 +0400 |
commit | 5d8a15985ecac279e8b08e49cc3e9af5b2af3a68 (patch) | |
tree | a626e4490145552680adc56d8f78841a210caad0 /vowpalwabbit/gd_mf.cc | |
parent | 15fd77423edf07315da39ad4954cdf59c6f492df (diff) |
cleaned learning algorithm interface per discussion with Miro
Diffstat (limited to 'vowpalwabbit/gd_mf.cc')
-rw-r--r-- | vowpalwabbit/gd_mf.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/vowpalwabbit/gd_mf.cc b/vowpalwabbit/gd_mf.cc index f3bba83c..6c2166a4 100644 --- a/vowpalwabbit/gd_mf.cc +++ b/vowpalwabbit/gd_mf.cc @@ -207,8 +207,9 @@ float mf_predict(vw& all, example* ex) return ex->final_prediction; } - void save_load(vw* all, void* d, io_buf& model_file, bool read, bool text) + void save_load(void* d, io_buf& model_file, bool read, bool text) { + vw* all = (vw*)d; uint32_t length = 1 << all->num_bits; uint32_t stride = all->stride; @@ -260,8 +261,9 @@ float mf_predict(vw& all, example* ex) } } - void learn(vw* all, void* d, example* ec) + void learn(void* d, example* ec) { + vw* all = (vw*)d; if (ec->end_pass) all->eta *= all->eta_decay_rate; @@ -273,7 +275,7 @@ float mf_predict(vw& all, example* ex) } } - void finish(vw* a, void* d) + void finish(void* d) { } void drive(vw* all, void* d) @@ -284,7 +286,7 @@ float mf_predict(vw& all, example* ex) { if ((ec = get_example(all->p)) != NULL)//blocking operation. { - learn(all,d,ec); + learn(d,ec); return_simple_example(*all, ec); } else if (parser_done(all->p)) @@ -296,7 +298,8 @@ float mf_predict(vw& all, example* ex) void setup(vw& all) { - learner t = {NULL,drive,learn,finish,save_load}; + sl_t sl = {&all, save_load}; + learner t = {&all,drive,learn,finish,sl}; all.l = t; } } |