classias::train::averaged_perceptron_base< error_tmpl > Class Template Reference

Inheritance diagram for classias::train::averaged_perceptron_base< error_tmpl >:

classias::train::averaged_perceptron_binary< error_tmpl > classias::train::averaged_perceptron_multi< error_tmpl >

Detailed Description

template<class error_tmpl>
class classias::train::averaged_perceptron_base< error_tmpl >

The base class for Averaged Preceptron.

This class implements internal variables, operations, and interface that are common for training a binary/multi classification.

Parameters:
error_tmpl The type of the error (loss) function.


Public Types

typedef error_tmpl error_type
 The type implementing an error function.
typedef error_type::model_type model_type
 The type implementing a model (weight vector for features).
typedef model_type::value_type value_type
 The type representing a value.
typedef averaged_perceptron_base<
error_tmpl > 
this_class
 A synonym of this class.

Public Member Functions

 averaged_perceptron_base ()
 Constructs the object.
virtual ~averaged_perceptron_base ()
 Destructs the object.
void clear ()
 Resets the internal states and parameters to default.
void set_num_features (size_t size)
 Sets the number of features.
void start ()
 Starts a training process.
void finish ()
 Terminates a training process.
void discontinue ()
void copyright (std::ostream &os)
 Shows the copyright information.
void report (std::ostream &os)
 Reports the current state of the training process.
parameter_exchangeparams ()
 Obtains the parameter interface.
model_typemodel ()
 Obtains an access to the weight vector (model).
const model_typemodel () const
 Obtains a read-only access to the weight vector (model).
value_type loss () const

Data Fields

report_type m_report

Protected Member Functions

void initialize_weights ()
 Initializes the weight vector.
void average_weights ()
 Finalizes the weight vector.

Protected Attributes

model_type m_w
 The array of feature weights (unaveraged or averaged).
model_type m_ws
 The array of cumulative feature weights used for computing the average.
bool m_averaged
 The indicator whether m_w is averaged or not.
value_type m_loss
 The loss.
int m_c
 The update count.
parameter_exchange m_params
 Parameter interface.

Data Structures

struct  report_type
 The type of progress information. More...


Member Function Documentation

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::set_num_features ( size_t  size  )  [inline]

Sets the number of features.

This function resizes the weight vector.

Parameters:
size The number of features.

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::start (  )  [inline]

Starts a training process.

This function resets the internal states, and prepares for a training process.

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::finish (  )  [inline]

Terminates a training process.

This function performs a post-processing after a training process.

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::copyright ( std::ostream &  os  )  [inline]

Shows the copyright information.

Parameters:
os The output stream.

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::report ( std::ostream &  os  )  [inline]

Reports the current state of the training process.

Parameters:
os The output stream.

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::initialize_weights (  )  [inline, protected]

Initializes the weight vector.

This function sets W = 0.

template<class error_tmpl>
void classias::train::averaged_perceptron_base< error_tmpl >::average_weights (  )  [inline, protected]

Finalizes the weight vector.

This function computes the actual weight vector W from the internal representation.

template<class error_tmpl>
parameter_exchange& classias::train::averaged_perceptron_base< error_tmpl >::params (  )  [inline]

Obtains the parameter interface.

Returns:
parameter_exchange& The parameter interface associated with this algorithm.

template<class error_tmpl>
model_type& classias::train::averaged_perceptron_base< error_tmpl >::model (  )  [inline]

Obtains an access to the weight vector (model).

Returns:
model_type& The weight vector (model).

template<class error_tmpl>
const model_type& classias::train::averaged_perceptron_base< error_tmpl >::model (  )  const [inline]

Obtains a read-only access to the weight vector (model).

Returns:
const model_type& The weight vector (model).


Copyright (c) 2002-2009 by Naoaki Okazaki
Mon Dec 28 23:41:07 2009