superviseddescent  0.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
Public Types | Public Member Functions | Friends | List of all members
superviseddescent::Regulariser Class Reference

#include <regressors.hpp>

Public Types

enum  RegularisationType { RegularisationType::Manual, RegularisationType::MatrixNorm }
 

Public Member Functions

 Regulariser (RegularisationType regularisation_type=RegularisationType::Manual, float param=0.0f, bool regularise_last_row=true)
 
cv::Mat get_matrix (cv::Mat data, int num_training_elements)
 

Friends

class cereal::access
 

Detailed Description

Regulariser class for the LinearRegressor.

Produces a diagonal matrix with a regularisation value (lambda) on the diagonal that can be added to the data matrix. Lambda can either be fixed or calculated from the data matrix.

Member Enumeration Documentation

The method to calculate the regularisation factor lambda.

Enumerator
Manual 

Use the given param value as lambda.

MatrixNorm 

Use \( \text{lambda} = \text{param} * \frac{\|\text{data}\|_2}{\text{numTrainingElements}} \) A suitable default for param suggested by the SDM authors is 0.5.

Constructor & Destructor Documentation

superviseddescent::Regulariser::Regulariser ( RegularisationType  regularisation_type = RegularisationType::Manual,
float  param = 0.0f,
bool  regularise_last_row = true 
)
inline

Create a new regulariser. Created with default parameters, it will not do any regularisation. Regulariser::RegularisationType can be used to specify the choice of the regularisation parameter lambda.

regularise_last_row is useful to specify the regularisation behaviour in the case the last row of the data matrix contains an affine (offset or bias) component. In that case, you might not want to regularise it (or maybe you do).

Parameters
[in]regularisation_typeSpecifies how to calculate lambda.
[in]paramLambda, or a factor, depending on regularisationType.
[in]regularise_last_rowSpecifies if the last row should be regularised.

Member Function Documentation

cv::Mat superviseddescent::Regulariser::get_matrix ( cv::Mat  data,
int  num_training_elements 
)
inline

Calculates a diagonal regularisation matrix, given the RegularisationType and param of the regulariser. It will have the same dimensions as the given data matrix.

Parameters
[in]dataData matrix that might be used to calculate an automatic value for lambda.
[in]num_training_elementsNumber of training elements.
Returns
Returns a diagonal regularisation matrix with the same dimensions as the given data matrix.

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