classias::train::lbfgs_base< model_tmpl > Class Template Reference

Inheritance diagram for classias::train::lbfgs_base< model_tmpl >:

classias::train::lbfgs_logistic_binary< data_tmpl, model_tmpl > classias::train::lbfgs_logistic_multi< data_tmpl, model_tmpl >

Detailed Description

template<class model_tmpl>
class classias::train::lbfgs_base< model_tmpl >

The base class for gradient descent using L-BFGS.

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

Parameters:
model_tmpl The type of a weight vector for features.


Public Types

typedef model_tmpl model_type
 The type implementing a model (weight vector for features).
typedef model_type::value_type value_type
 The type representing a value.
typedef lbfgs_base< model_tmpl > this_class
 A synonym of this class.

Public Member Functions

 lbfgs_base ()
 Constructs the object.
virtual ~lbfgs_base ()
 Destructs the object.
void clear ()
 Resets the internal states and parameters to default.
parameter_exchangeparams ()
 Obtains the parameter interface.
const model_typemodel () const
 Obtains a read-only access to the weight vector (model).

Protected Member Functions

void initialize_weights (const size_t K)
 Initializes the weight vector of the size K.
value_type lbfgs_evaluate (const value_type *x, value_type *g, const int n, const value_type step)
int lbfgs_progress (const value_type *x, const value_type *g, const value_type fx, const value_type xnorm, const value_type gnorm, const value_type step, int n, int k, int ls)
int lbfgs_solve (const int K, std::ostream &os, int holdout, int regularization_start)
void lbfgs_output_status (std::ostream &os, int status)
virtual value_type loss_and_gradient (const value_type *x, value_type *g, const int n)=0
virtual void holdout_evaluation ()=0

Static Protected Member Functions

static value_type __lbfgs_evaluate (void *inst, const value_type *x, value_type *g, const int n, const value_type step)
static int __lbfgs_progress (void *inst, const double *x, const double *g, const double fx, const double xnorm, const double gnorm, const double step, int n, int k, int ls)

Protected Attributes

model_type m_w
 The array of feature weights.
parameter_exchange m_params
 Parameter interface.
value_type m_c1
 Coefficient for L1-regularization;.
value_type m_c2
 Coefficient for L2-regularization.
int m_lbfgs_num_memories
 The number of memories in L-BFGS.
value_type m_lbfgs_epsilon
 L-BFGS epsilon for convergence.
int m_lbfgs_stop
 Number of iterations for stopping criterion.
value_type m_lbfgs_delta
 The delta threshold for stopping criterion.
int m_lbfgs_maxiter
 Maximum number of L-BFGS iterations.
std::string m_lbfgs_linesearch
 Line search algorithm.
int m_lbfgs_max_linesearch
 The maximum number of trials for the line search algorithm.
int m_holdout
 A group number for holdout evaluation.
std::ostream * m_os
 An output stream to which this object outputs log messages.
clock_t m_clk_prev
 An internal variable (previous timestamp).
int m_regularization_start
 The start index for regularization.


Member Function Documentation

template<class model_tmpl>
void classias::train::lbfgs_base< model_tmpl >::initialize_weights ( const size_t  K  )  [inline, protected]

Initializes the weight vector of the size K.

This function prepares a vector of the size K, and sets W = 0.

Parameters:
K The size of the weight vector.

template<class model_tmpl>
parameter_exchange& classias::train::lbfgs_base< model_tmpl >::params (  )  [inline]

Obtains the parameter interface.

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

template<class model_tmpl>
const model_type& classias::train::lbfgs_base< model_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