CRF Model
The Binary LN Model described in the bachelor thesis "Maximum Likelihood Learning And Inference In Conditional Random Fields" by Iulian Vlad Serban, University of Copenhagen, 2012.
CRF::CRFModel Class Reference
Inheritance diagram for CRF::CRFModel:
CRF::CRFModel_GraphCut CRF::CRFModel_CD

List of all members.

Public Member Functions

 CRFModel ()
 CRFModel (int imgWidth, int imgHeight, int MAPSTEPS)
virtual int_int_vector EstimateMAP (const double_double_vector Input)
double EstimateLogLikelihood (const double_double_vector &Input, const int_int_vector &Output)
virtual void EstimateModelParameters (const std::vector< double_double_vector > &InputSamples, const std::vector< int_int_vector > &OutputSamples, size_t Steps, double StepFactor)

Protected Member Functions

double EvaluatePartitionFunction (const double_double_vector &Input)
double_vector EvaluateExpectedFeatureFunction (const double_double_vector &Input)
double EvaluateOutputEnergy (const double_double_vector &Input, const int_int_vector &Output)
double EvaluateNodeEnergy (const double_double_vector Input, const int_int_vector Output, size_t i, size_t j)
double_vector EvaluateNodeVector (const double_double_vector Input, const int_int_vector Output, size_t i, size_t j)
int_vector ConvertToNewNumberRepresentation (int number, int newRepresentationSymbolCount, int maxDigits)

Protected Attributes

double_vector weights
size_t imageWidth
size_t imageHeight
size_t paramCount
size_t statesCount
size_t MAPSteps

Constructor & Destructor Documentation

Constructor that initializes the configuration of the model. Width and Height are set to 1 pixel.

CRFModel::CRFModel ( int  imgWidth,
int  imgHeight,
int  MAPSTEPS 
)

Constructor that initializes the configuration of the model.

Parameters:
imgWidthImage width in pixels.
imgHeightImage height in pixels.
MAPSTEPSMaximum number of steps to perform MAP estimation.

Member Function Documentation

int_vector CRFModel::ConvertToNewNumberRepresentation ( int  number,
int  newRepresentationSymbolCount,
int  maxDigits 
) [protected]

Converts an int (in the decimal numeral system, base-10) to an int [] (in any other numerical system, base-k). This function is used by EvaluatePartitionFunction and EvaluateExpectedFeatureFunction to loop through all the possible configurations.

Parameters:
numberNumber to be converted.
newRepresentationSymbolCountNumber of distinct symbols in the new numeral system.
maxDigitsThe maxmimum number of digits.
Returns:
An int_vector where each entry in the array corresponds to a seperate symbol in the new numeral system. The vector has size maxDigits.
double CRFModel::EstimateLogLikelihood ( const double_double_vector &  Input,
const int_int_vector &  Output 
)

Estimates the exact loglikelihood for a given input sample and output.

Parameters:
InputInput sample.
OutputOutput sample.
Returns:
MAP solution.
int_int_vector CRFModel::EstimateMAP ( const double_double_vector  Input) [virtual]

Estimates the MAP (Maximum Aposterori Estimation) solution. By default, the Iterated Conditional Modes algorithm is used.

Parameters:
InputInput sample.
Returns:
MAP solution.

Reimplemented in CRF::CRFModel_GraphCut.

void CRFModel::EstimateModelParameters ( const std::vector< double_double_vector > &  InputSamples,
const std::vector< int_int_vector > &  OutputSamples,
size_t  Steps,
double  StepFactor 
) [virtual]

Estimates the model parameters using steepest decent.

Parameters:
InputSamplesArray of input samples. The format is InputSamples[i] = Input Sample i.
OutputSamplesArray of correctly classified output samples. The format is OutputSamples[i] = Output Sample i.
StepsNumber of steps to perform steepest decent before terminating.
StepFactorFactor determining the step length (in the direction of the loglikelihood gradient) of each iteration. Should be greater than zero and likely less than one. (The actual step length taken is multiplied by the preprocessor variable FeatureFunctionScaleDivision, which was divided by in the function EvaluateNodeVector to improve numerical accuracy on the partition function. This is just a computational practicality and will not affect any other calculations.).

Reimplemented in CRF::CRFModel_CD.

double_vector CRFModel::EvaluateExpectedFeatureFunction ( const double_double_vector &  Input) [protected]

Function used to estimate the exact partition function and the exact expected feature functions.

Parameters:
InputInput sample.
Returns:
The partition function and the expected feature functions (under the models pdf). The forrmat is: Ret[0] = Partition Function, Ret[1] = expected feature function 0, ..., Ret[paramCount + 1] = value of expected feature function paramCount.
double CRFModel::EvaluateNodeEnergy ( const double_double_vector  Input,
const int_int_vector  Output,
size_t  i,
size_t  j 
) [protected]

Estimates the energy at a specific node for a given input and output sample.

Parameters:
InputInput sample.
OutputOutput sample.
Returns:
The energy for the specific node.
double_vector CRFModel::EvaluateNodeVector ( const double_double_vector  Input,
const int_int_vector  Output,
size_t  i,
size_t  j 
) [protected]

Estimates the vector for a given node. Summing these vectors for all the nodes and taking the inner product with the Weights will yield the energy for a given input and output sample. NOTICE: These values are divided by the preprocessor variable FeatureFunctionScaleDivision to improve numerical accuracy when doing calculations with the partition function.

Parameters:
InputInput sample.
OutputOutput sample.
ihorizontal position of node.
jvertical position of node.
Returns:
A node vector.
double CRFModel::EvaluateOutputEnergy ( const double_double_vector &  Input,
const int_int_vector &  Output 
) [protected]

Estimates the energy function for a given input and output sample.

Parameters:
InputInput sample.
OutputOutput sample.
Returns:
The energy function.
double CRFModel::EvaluatePartitionFunction ( const double_double_vector &  Input) [protected]

Function used to estimate the exact partition function.

Parameters:
InputInput sample.
Returns:
The exact partition function.

Member Data Documentation

size_t CRF::CRFModel::imageHeight [protected]

The image height. imageWidth times imageHeight equals the number nodes in the model. For exact inference should be <= 4. Otherwise the calculations become intractable.

size_t CRF::CRFModel::imageWidth [protected]

The image width. imageWidth times imageHeight equals the number nodes in the model. For exact inference should be <= 4. Otherwise the calculations become intractable.

size_t CRF::CRFModel::MAPSteps [protected]

Number of maximum iterations for the Iterated Conditional Modes algorithm.

size_t CRF::CRFModel::paramCount [protected]

The number of weights (parameters). It has to equal the number of Weights (Weights.size()). Standard value: 5. (This is model specific so changes here will require changes in the source code.)

size_t CRF::CRFModel::statesCount [protected]

The number of states of each node. Standard value: 2 for black and white. (This is model specific so changes here will require changes in the source code.)

double_vector CRF::CRFModel::weights [protected]

The parameters of the model. The format is Weights[k] equals the weight of feature function k.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables