Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cb_explore_adf_bag.cc make_reduction_learner #3016

Merged
merged 6 commits into from May 21, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions vowpalwabbit/cb_explore_adf_bag.cc
Expand Up @@ -12,6 +12,7 @@
#include "gen_cs_example.h"
#include "cb_explore.h"
#include "explore.h"
#include "label_parser.h"
#include <vector>
#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -178,16 +179,18 @@ VW::LEARNER::base_learner* setup(VW::config::options_i& options, vw& all)
bool with_metrics = options.was_supplied("extra_metrics");

using explore_type = cb_explore_adf_base<cb_explore_adf_bag>;
auto data = scoped_calloc_or_throw<explore_type>(
with_metrics, epsilon, bag_size, greedify, first_only, all.get_random_state());

VW::LEARNER::learner<explore_type, multi_ex>& l = VW::LEARNER::init_learner(data, base, explore_type::learn,
explore_type::predict, problem_multiplier, prediction_type_t::action_probs, all.get_setupfn_name(setup) + "-bag");

l.set_finish_example(finish_bag_example);
l.set_print_example(print_bag_example);
l.set_persist_metrics(explore_type::persist_metrics);
return make_base(l);
auto data =
VW::make_unique<explore_type>(with_metrics, epsilon, bag_size, greedify, first_only, all.get_random_state());
auto* l = make_reduction_learner(
std::move(data), base, explore_type::learn, explore_type::predict, all.get_setupfn_name(setup) + "-bag")
.set_params_per_weight(problem_multiplier)
.set_prediction_type(prediction_type_t::action_probs)
.set_label_type(label_type_t::cb)
.set_finish_example(finish_bag_example)
.set_print_example(print_bag_example)
.set_persist_metrics(explore_type::persist_metrics)
.build();
return make_base(*l);
}

} // namespace bag
Expand Down