SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
所有成员列表 | Public 成员函数 | Protected 成员函数 | Protected 属性
FirstOrderMinimizer类 参考abstract

详细描述

The first order minimizer base class.

This class gives the interface of a first-order gradient-based unconstrained minimizer

This kind of minimizers will find optimal target variables based on gradient information wrt target variables. For example, the gradient descend method is a minimizer.

A minimizer requires the following objects as input: a supported cost function object (eg, FirstOrderCostFunction ) a penalty object if regularization is enabled (eg, Penalty ) a context object to restore mutable variables if deserialization is actived (eg, CMinimizerContext )

在文件 FirstOrderMinimizer.h54 行定义.

类 FirstOrderMinimizer 继承关系图:
Inheritance graph
[图例]

Public 成员函数

 FirstOrderMinimizer ()
 
 FirstOrderMinimizer (FirstOrderCostFunction *fun)
 
virtual ~FirstOrderMinimizer ()
 
virtual float64_t minimize ()=0
 
virtual bool supports_batch_update () const =0
 
virtual void set_cost_function (FirstOrderCostFunction *fun)
 
virtual CMinimizerContextsave_to_context ()
 
virtual void load_from_context (CMinimizerContext *context)
 
virtual void set_penalty_weight (float64_t penalty_weight)
 
virtual void set_penalty_type (Penalty *penalty_type)
 

Protected 成员函数

virtual void update_context (CMinimizerContext *context)
 
virtual float64_t get_penalty (SGVector< float64_t > var)
 
virtual void update_gradient (SGVector< float64_t > gradient, SGVector< float64_t > var)
 

Protected 属性

FirstOrderCostFunctionm_fun
 
Penaltym_penalty_type
 
float64_t m_penalty_weight
 

构造及析构函数说明

Default constructor

在文件 FirstOrderMinimizer.h58 行定义.

Constructor

参数
funcost function (user have to manully delete the pointer)

在文件 FirstOrderMinimizer.h66 行定义.

virtual ~FirstOrderMinimizer ( )
virtual

Destructor

在文件 FirstOrderMinimizer.h73 行定义.

成员函数说明

virtual float64_t get_penalty ( SGVector< float64_t var)
protectedvirtual

Get the penalty given target variables For L2 penalty, the target variable is \(w\) and the value of penalty is \(\lambda \frac{w^t w}{2}\), where \(\lambda\) is the weight of penalty

参数
varthe variable used in regularization

在文件 FirstOrderMinimizer.h164 行定义.

virtual void load_from_context ( CMinimizerContext context)
virtual

Load the given context object to restores mutable variables Usually it is used in deserialization.

参数
contexta context object

LBFGSMinimizer, FirstOrderStochasticMinimizer, NLOPTMinimizer, SMDMinimizer , 以及 SMIDASMinimizer 重载.

在文件 FirstOrderMinimizer.h115 行定义.

virtual float64_t minimize ( )
pure virtual

Do minimization and get the optimal value

返回
optimal value

FirstOrderStochasticMinimizer, LBFGSMinimizer, SMIDASMinimizer, NLOPTMinimizer, SVRGMinimizer, SGDMinimizer , 以及 SMDMinimizer 内被实现.

virtual CMinimizerContext* save_to_context ( )
virtual

Return a context object which stores mutable variables Usually it is used in serialization.

返回
a context object

LBFGSMinimizer , 以及 NLOPTMinimizer 重载.

在文件 FirstOrderMinimizer.h103 行定义.

virtual void set_cost_function ( FirstOrderCostFunction fun)
virtual

Set cost function used in the minimizer

参数
funthe cost function

在文件 FirstOrderMinimizer.h92 行定义.

virtual void set_penalty_type ( Penalty penalty_type)
virtual

Set the type of penalty For example, L2 penalty

参数
penalty_typethe type of penalty. If NULL is given, regularization is not enabled.

在文件 FirstOrderMinimizer.h137 行定义.

virtual void set_penalty_weight ( float64_t  penalty_weight)
virtual

Set the weight of penalty

参数
penalty_weightthe weight of penalty, which is positive

在文件 FirstOrderMinimizer.h126 行定义.

virtual bool supports_batch_update ( ) const
pure virtual

Does minimizer support batch update?

返回
whether minimizer supports batch update

FirstOrderStochasticMinimizer, LBFGSMinimizer , 以及 NLOPTMinimizer 内被实现.

virtual void update_context ( CMinimizerContext context)
protectedvirtual

Update a context object to store mutable variables

参数
contexta context object

FirstOrderStochasticMinimizer, SMDMinimizer , 以及 SMIDASMinimizer 重载.

在文件 FirstOrderMinimizer.h147 行定义.

virtual void update_gradient ( SGVector< float64_t gradient,
SGVector< float64_t var 
)
protectedvirtual

Add gradient of the penalty wrt target variables to unpenalized gradient For least sqaure with L2 penalty,

\[ L2f(w)=f(w) + L2(w) \]

where \( f(w)=\sum_i{(y_i-w^T x_i)^2}\) is the least sqaure cost function and \(L2(w)=\lambda \frac{w^t w}{2}\) is the L2 penalty

Target variables is \(w\) Unpenalized gradient is \(\frac{\partial f(w) }{\partial w}\) Gradient of the penalty wrt target variables is \(\frac{\partial L2(w) }{\partial w}\)

参数
gradientunpenalized gradient wrt its target variable
varthe target variable

在文件 FirstOrderMinimizer.h190 行定义.

类成员变量说明

FirstOrderCostFunction* m_fun
protected

Cost function

在文件 FirstOrderMinimizer.h205 行定义.

Penalty* m_penalty_type
protected

the type of penalty

在文件 FirstOrderMinimizer.h208 行定义.

float64_t m_penalty_weight
protected

the weight of penalty

在文件 FirstOrderMinimizer.h211 行定义.


该类的文档由以下文件生成:

SHOGUN 机器学习工具包 - 项目文档