Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
reranker::TrainingVectorSet Class Reference

A class to hold the several feature vectors needed during training (especially for the perceptron family of algorithms), as well as for performing the updates to those feature vectors (again, with the perceptron family of algorithms in mind). More...

#include <training-vector-set.H>

Public Member Functions

 TrainingVectorSet ()
 Constructs a new set of feature vectors (models) for use during training. More...
 
virtual ~TrainingVectorSet ()
 Destroys this instance. More...
 
const FeatureVector< int,
double > & 
weights () const
 Returns the "raw" feature weights computed during training. More...
 
const FeatureVector< int,
double > & 
average_weights () const
 Returns the feature vector corresponding to the averaged perceptron. More...
 
const FeatureVector< int,
double > & 
GetModel (bool raw) const
 Returns either the raw or averaged feature vector, depending on the argument. More...
 
template<typename Collection >
void UpdateWeights (const Time &time, const Collection &feature_uids, const FeatureVector< int, double > &feature_vector, double scalar)
 Increments the weights for the specified collection of features. More...
 
template<typename Collection >
void UpdateGoldAndCandidateFeatureAverages (const Time &time, const Collection &gold_feature_uids, const Collection &candidate_feature_uids)
 Updates the feature averages the specified pair of feature uid collections, one for a gold reference training instance and the other for a one-best hypothesis. More...
 
void UpdateAllFeatureAverages (const Time &time)
 
void RemapFeatureUids (const unordered_map< int, int > &old_to_new_uids)
 

Friends

class PerceptronModelProtoReader
 
ostream & operator<< (ostream &os, const TrainingVectorSet &tvs)
 

Detailed Description

A class to hold the several feature vectors needed during training (especially for the perceptron family of algorithms), as well as for performing the updates to those feature vectors (again, with the perceptron family of algorithms in mind).

Definition at line 59 of file training-vector-set.H.

Constructor & Destructor Documentation

reranker::TrainingVectorSet::TrainingVectorSet ( )
inline

Constructs a new set of feature vectors (models) for use during training.

Definition at line 63 of file training-vector-set.H.

virtual reranker::TrainingVectorSet::~TrainingVectorSet ( )
inlinevirtual

Destroys this instance.

Definition at line 65 of file training-vector-set.H.

Member Function Documentation

const FeatureVector<int,double>& reranker::TrainingVectorSet::average_weights ( ) const
inline

Returns the feature vector corresponding to the averaged perceptron.

Definition at line 74 of file training-vector-set.H.

const FeatureVector<int,double>& reranker::TrainingVectorSet::GetModel ( bool  raw) const
inline

Returns either the raw or averaged feature vector, depending on the argument.

Parameters
rawif true, return the raw model; otherwise, return the averaged perceptron model

Definition at line 83 of file training-vector-set.H.

void reranker::TrainingVectorSet::RemapFeatureUids ( const unordered_map< int, int > &  old_to_new_uids)
inline

Definition at line 136 of file training-vector-set.H.

void reranker::TrainingVectorSet::UpdateAllFeatureAverages ( const Time time)
inline

Definition at line 128 of file training-vector-set.H.

template<typename Collection >
void reranker::TrainingVectorSet::UpdateGoldAndCandidateFeatureAverages ( const Time time,
const Collection &  gold_feature_uids,
const Collection &  candidate_feature_uids 
)
inline

Updates the feature averages the specified pair of feature uid collections, one for a gold reference training instance and the other for a one-best hypothesis.

Definition at line 115 of file training-vector-set.H.

template<typename Collection >
void reranker::TrainingVectorSet::UpdateWeights ( const Time time,
const Collection &  feature_uids,
const FeatureVector< int, double > &  feature_vector,
double  scalar 
)
inline

Increments the weights for the specified collection of features.

Technically, this method adds a scaled version of the specified vector projected into the subspace specified by the collection of feature uid's.

Parameters
timethe current training time
feature_uidsthe set of features to be updated (essentially a subspace into which to project feature_vector)
feature_vectorthe feature vector to be projected into the specified subspace, scaled and then added to the current set of model weights
scalarthe amount by which to scale the specified subvector
See Also
FeatureVector::AddScaledSubvector

Definition at line 104 of file training-vector-set.H.

const FeatureVector<int,double>& reranker::TrainingVectorSet::weights ( ) const
inline

Returns the "raw" feature weights computed during training.

This is essentially the "most recent" perceptron created during training.

Definition at line 72 of file training-vector-set.H.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const TrainingVectorSet tvs 
)
friend

Definition at line 144 of file training-vector-set.H.

friend class PerceptronModelProtoReader
friend

Definition at line 61 of file training-vector-set.H.


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