Vowpal Wabbit
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
VW::autolink Struct Reference

Public Member Functions

 autolink (uint32_t d, uint32_t stride_shift)
 
void predict (LEARNER::single_learner &base, example &ec)
 
void learn (LEARNER::single_learner &base, example &ec)
 

Private Member Functions

void prepare_example (LEARNER::single_learner &base, example &ec)
 
void reset_example (example &ec)
 

Private Attributes

const uint32_t _poly_degree
 
const uint32_t _stride_shift
 

Static Private Attributes

static constexpr int AUTOCONSTANT = 524267083
 

Detailed Description

Definition at line 13 of file autolink.cc.

Constructor & Destructor Documentation

◆ autolink()

VW::autolink::autolink ( uint32_t  d,
uint32_t  stride_shift 
)

Definition at line 30 of file autolink.cc.

31  : _poly_degree(poly_degree), _stride_shift(stride_shift)
32 {
33 }
uint64_t stride_shift(const stagewise_poly &poly, uint64_t idx)

Member Function Documentation

◆ learn()

void VW::autolink::learn ( LEARNER::single_learner base,
example ec 
)

Definition at line 42 of file autolink.cc.

References LEARNER::learner< T, E >::learn(), prepare_example(), and reset_example().

Referenced by predict_or_learn().

43 {
44  prepare_example(base, ec);
45  base.learn(ec);
46  reset_example(ec);
47 }
void learn(E &ec, size_t i=0)
Definition: learner.h:160

◆ predict()

void VW::autolink::predict ( LEARNER::single_learner base,
example ec 
)

Definition at line 35 of file autolink.cc.

References LEARNER::learner< T, E >::predict(), prepare_example(), and reset_example().

Referenced by predict_or_learn().

36 {
37  prepare_example(base, ec);
38  base.predict(ec);
39  reset_example(ec);
40 }
void predict(E &ec, size_t i=0)
Definition: learner.h:169

◆ prepare_example()

void VW::autolink::prepare_example ( LEARNER::single_learner base,
example ec 
)
private

Definition at line 49 of file autolink.cc.

References _poly_degree, _stride_shift, AUTOCONSTANT, autolink_namespace, example_predict::feature_space, example_predict::indices, example::pred, LEARNER::learner< T, E >::predict(), v_array< T >::push_back(), features::push_back(), polyprediction::scalar, features::sum_feat_sq, and example::total_sum_feat_sq.

Referenced by learn(), and predict().

50 {
51  base.predict(ec);
52  float base_pred = ec.pred.scalar;
53 
54  // Add features of label.
57  for (size_t i = 0; i < _poly_degree; i++)
58  {
59  if (base_pred != 0.)
60  {
61  fs.push_back(base_pred, AUTOCONSTANT + (i << _stride_shift));
62  base_pred *= ec.pred.scalar;
63  }
64  }
66 }
v_array< namespace_index > indices
void predict(E &ec, size_t i=0)
Definition: learner.h:169
void push_back(feature_value v, feature_index i)
float scalar
Definition: example.h:45
the core definition of a set of features.
std::array< features, NUM_NAMESPACES > feature_space
void push_back(const T &new_ele)
Definition: v_array.h:107
constexpr unsigned char autolink_namespace
Definition: constant.h:24
float total_sum_feat_sq
Definition: example.h:71
float sum_feat_sq
polyprediction pred
Definition: example.h:60

◆ reset_example()

void VW::autolink::reset_example ( example ec)
private

Definition at line 68 of file autolink.cc.

References autolink_namespace, features::clear(), example_predict::feature_space, example_predict::indices, v_array< T >::pop(), features::sum_feat_sq, and example::total_sum_feat_sq.

Referenced by learn(), and predict().

69 {
72  fs.clear();
73  ec.indices.pop();
74 }
v_array< namespace_index > indices
T pop()
Definition: v_array.h:58
the core definition of a set of features.
std::array< features, NUM_NAMESPACES > feature_space
void clear()
constexpr unsigned char autolink_namespace
Definition: constant.h:24
float total_sum_feat_sq
Definition: example.h:71
float sum_feat_sq

Member Data Documentation

◆ _poly_degree

const uint32_t VW::autolink::_poly_degree
private

Definition at line 24 of file autolink.cc.

Referenced by prepare_example().

◆ _stride_shift

const uint32_t VW::autolink::_stride_shift
private

Definition at line 25 of file autolink.cc.

Referenced by prepare_example().

◆ AUTOCONSTANT

constexpr int VW::autolink::AUTOCONSTANT = 524267083
staticprivate

Definition at line 26 of file autolink.cc.

Referenced by prepare_example().


The documentation for this struct was generated from the following file: