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.
|
00001 00037 #include <vector> 00038 #include <stdlib.h> 00039 #include <math.h> 00040 #ifndef CRFMODEL_H 00041 #define CRFMODEL_H 00042 00043 typedef std::vector<double> double_vector; 00044 typedef std::vector< std::vector<double> > double_double_vector; 00045 00046 typedef std::vector<size_t> int_vector; 00047 typedef std::vector< std::vector<size_t> > int_int_vector; 00048 00049 namespace CRF 00050 { 00051 00052 class CRFModel 00053 { 00054 public: 00058 CRFModel(); 00059 00066 CRFModel(int imgWidth, int imgHeight, int MAPSTEPS); 00067 00073 virtual int_int_vector EstimateMAP(const double_double_vector Input); 00074 00081 double EstimateLogLikelihood(const double_double_vector & Input, const int_int_vector & Output); 00082 00092 virtual void EstimateModelParameters(const std::vector<double_double_vector> & InputSamples, const std::vector<int_int_vector> & OutputSamples, size_t Steps, double StepFactor); 00093 00094 protected: 00098 double_vector weights; 00099 00104 size_t imageWidth; 00105 00110 size_t imageHeight; 00111 00116 size_t paramCount; 00117 00122 size_t statesCount; 00123 00127 size_t MAPSteps; 00128 00129 00136 double EvaluatePartitionFunction(const double_double_vector & Input); 00137 00145 double_vector EvaluateExpectedFeatureFunction(const double_double_vector & Input); 00146 00153 double EvaluateOutputEnergy(const double_double_vector & Input, const int_int_vector & Output); 00154 00161 double EvaluateNodeEnergy(const double_double_vector Input, const int_int_vector Output, size_t i, size_t j); 00162 00172 double_vector EvaluateNodeVector(const double_double_vector Input, const int_int_vector Output, size_t i, size_t j); 00173 00182 int_vector ConvertToNewNumberRepresentation(int number, int newRepresentationSymbolCount, int maxDigits); 00183 00184 }; 00185 00186 00187 } 00188 00189 #endif // CRFMODEL_H