Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Langford <jl@nyclamp.(none)>2014-01-09 00:01:11 +0400
committerJohn Langford <jl@nyclamp.(none)>2014-01-09 00:01:11 +0400
commit5336bffc0d67fb224c90553f4aceaea671bcbd77 (patch)
treefe79f7ea9074a37b356da7d984a08a216daea040 /vowpalwabbit/cbify.cc
parente258410d86feda58859ecc695940b816de26a8f2 (diff)
finished void* removal in learner.h
Diffstat (limited to 'vowpalwabbit/cbify.cc')
-rw-r--r--vowpalwabbit/cbify.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/vowpalwabbit/cbify.cc b/vowpalwabbit/cbify.cc
index 2bd82348..e675c0cd 100644
--- a/vowpalwabbit/cbify.cc
+++ b/vowpalwabbit/cbify.cc
@@ -36,10 +36,8 @@ namespace CBIFY {
}
template <bool is_learn>
- void predict_or_learn_first(void* d, learner& base, example* ec)
+ void predict_or_learn_first(cbify* data, learner& base, example* ec)
{//Explore tau times, then act according to optimal.
- cbify* data = (cbify*)d;
-
OAA::mc_label* ld = (OAA::mc_label*)ec->ld;
//Use CB to find current prediction for remaining rounds.
if (data->tau > 0)
@@ -74,11 +72,8 @@ namespace CBIFY {
}
template <bool is_learn>
- void predict_or_learn_greedy(void* d, learner& base, example* ec)
+ void predict_or_learn_greedy(cbify* data, learner& base, example* ec)
{//Explore uniform random an epsilon fraction of the time.
- cbify* data = (cbify*)d;
-
- //Use CB to find current prediction.
OAA::mc_label* ld = (OAA::mc_label*)ec->ld;
data->cb_label.costs.erase();
@@ -169,17 +164,19 @@ namespace CBIFY {
}
*(all.p->lp) = OAA::mc_label_parser;
- learner* l;
+ learner* l = new learner(data, all.l, 1);
if (vm.count("first") )
{
data->tau = (uint32_t)vm["first"].as<size_t>();
- l = new learner(data, predict_or_learn_first<true>, predict_or_learn_first<false>, all.l, 1);
+ l->set_learn<cbify, predict_or_learn_first<true> >();
+ l->set_predict<cbify, predict_or_learn_first<false> >();
}
else
{
if ( vm.count("greedy") )
data->epsilon = vm["greedy"].as<float>();
- l = new learner(data, predict_or_learn_greedy<true>, predict_or_learn_greedy<false>, all.l, 1);
+ l->set_learn<cbify, predict_or_learn_greedy<true> >();
+ l->set_predict<cbify, predict_or_learn_greedy<false> >();
}
l->set_finish_example<cbify,finish_example>();