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 | List of all members
reranker::PerceptronModelProtoWriter Class Reference

A class to construct a ModelMessage from a PerceptronModel instance. More...

#include <perceptron-model-proto-writer.H>

Inheritance diagram for reranker::PerceptronModelProtoWriter:
reranker::ModelProtoWriter reranker::FactoryConstructible

Public Member Functions

 PerceptronModelProtoWriter ()
 Constructs a new instance that can serialize Model instances to ModelMessage protocol buffer messages. More...
 
virtual ~PerceptronModelProtoWriter ()
 Destroys this writer. More...
 
virtual void Write (const Model *model, ModelMessage *model_message, bool write_features) const
 Serializes a PerceptronModel instance to a ModelMessage. More...
 
virtual void WriteFeatures (const Model *model, ostream &os, bool output_best_epoch, double weight, bool output_key, const string separator) const
 Writes out the features of this model to a series of FeatureMessage instances using the specified ConfusionProtoIO instance. More...
 
- Public Member Functions inherited from reranker::ModelProtoWriter
 ModelProtoWriter ()
 Constructs a new instance that can serialize Model instances to ModelMessage protocol buffer messages. More...
 
virtual ~ModelProtoWriter ()
 Destroys this writer. More...
 
- Public Member Functions inherited from reranker::FactoryConstructible
virtual ~FactoryConstructible ()
 
virtual void RegisterInitializers (Initializers &initializers)
 
virtual void Init (const Environment *env, const string &arg)
 

Detailed Description

A class to construct a ModelMessage from a PerceptronModel instance.

TODO(dbikel): Need some kind of a factory for model writers, so the proper ModelProtoWriter gets instantiated given a particular Model subclass.

Definition at line 58 of file perceptron-model-proto-writer.H.

Constructor & Destructor Documentation

reranker::PerceptronModelProtoWriter::PerceptronModelProtoWriter ( )
inline

Constructs a new instance that can serialize Model instances to ModelMessage protocol buffer messages.

Definition at line 62 of file perceptron-model-proto-writer.H.

virtual reranker::PerceptronModelProtoWriter::~PerceptronModelProtoWriter ( )
inlinevirtual

Destroys this writer.

Definition at line 64 of file perceptron-model-proto-writer.H.

Member Function Documentation

void reranker::PerceptronModelProtoWriter::Write ( const Model model,
ModelMessage *  model_message,
bool  write_features 
) const
virtual

Serializes a PerceptronModel instance to a ModelMessage.

When the write_features parameter is true, the feature vectors written out will be those of the best model epoch (typically the epoch with the lowest average devtest loss).

Parameters
modelthe PerceptronModel to be serialized to the specified ModelMessage
model_messagethe ModelMessage to be filled in by this method with the serialized version of the specified Model
write_featureswhether the features of the specified Model should be written out

Implements reranker::ModelProtoWriter.

Definition at line 52 of file perceptron-model-proto-writer.C.

void reranker::PerceptronModelProtoWriter::WriteFeatures ( const Model model,
ostream &  os,
bool  output_best_epoch,
double  weight,
bool  output_key,
const string  separator 
) const
virtual

Writes out the features of this model to a series of FeatureMessage instances using the specified ConfusionProtoIO instance.

This method writes out both the raw feature values as well as the averaged values; however, the averaged values are stored in the avg_value field of the FeatureMessage object. In contrast to the behavior of the Write method, the features written out by this method will be those of the current model, as opposed to those of the best model.

Parameters
modelthe PerceptronModel to be serialized to the specified ModelMessage
osthe output stream to which to write features
output_best_epochoutput the weights of the best epoch of training, as opposed to the most recent epoch
weightthe weight by which all feature weights should be multiplied before being output
output_keyoutput the key (feature name) and separator for each feature
separatorthe separator string to output between each feature’s key and its base64-encoded FeatureMessage (only used if output_key == True)

Implements reranker::ModelProtoWriter.

Definition at line 95 of file perceptron-model-proto-writer.C.


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