SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
List of all members | Public Member Functions
FirstOrderStochasticCostFunction Class Referenceabstract

Detailed Description

The first order stochastic cost function base class.

The class gives the interface used in first order stochastic minimizers

The cost function must be Written as a finite sample-specific sum of cost. For example, least squares cost function,

\[ f(w)=\frac{ \sum_i{ (y_i-w^T x_i)^2 } }{2} \]

where \((y_i,x_i)\) is the i-th sample, \(y_i\) is the label and \(x_i\) is the features

Definition at line 50 of file FirstOrderStochasticCostFunction.h.

Inheritance diagram for FirstOrderStochasticCostFunction:
Inheritance graph
[legend]

Public Member Functions

virtual void begin_sample ()=0
 
virtual bool next_sample ()=0
 
virtual SGVector< float64_tget_gradient ()=0
 
virtual float64_t get_cost ()=0
 
virtual SGVector< float64_tobtain_variable_reference ()=0
 

Member Function Documentation

virtual void begin_sample ( )
pure virtual

Initialize to generate a sample sequence

virtual float64_t get_cost ( )
pure virtual

Get the cost given current target variables

For least squares, that is the value of \(f(w)\).

Returns
cost

Implements FirstOrderCostFunction.

Implemented in FirstOrderSAGCostFunction.

virtual SGVector<float64_t> get_gradient ( )
pure virtual

Get the SAMPLE gradient value wrt target variables

WARNING This method does return \( \frac{\partial f_i(w) }{\partial w} \), instead of \(\sum_i{ \frac{\partial f_i(w) }{\partial w} }\)

For least squares cost function, that is the value of \(\frac{\partial f_i(w) }{\partial w}\) given \(w\) is known where the index \(i\) is obtained by next_sample()

Returns
sample gradient of variables

Implements FirstOrderCostFunction.

Implemented in FirstOrderSAGCostFunction.

virtual bool next_sample ( )
pure virtual

Get next sample

Returns
false if reach the end of the sample sequence
virtual SGVector<float64_t> obtain_variable_reference ( )
pure virtualinherited

Obtain a reference of target variables Minimizers will modify target variables in place.

This method will be called by FirstOrderMinimizer::minimize()

For least squares, that is \(w\)

Returns
reference of variables

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

SHOGUN Machine Learning Toolbox - Documentation