Direct Graphical Models  v.1.7.0
TrainEdge.h
1 // Base abstract class for random model edges training
2 // Written by Sergey G. Kosov in 2013-2015 for Project X
3 #pragma once
4 
5 #include "ITrain.h"
6 
7 namespace DirectGraphicalModels
8 {
10  enum EdgeRandomModel : byte {
11  Potts = 0,
15  };
16 
17  // ============================= Edge Train Class =============================
24  class CTrainEdge : public ITrain
25  {
26  public:
32  DllExport CTrainEdge(byte nStates, word nFeatures) : CBaseRandomModel(nStates), ITrain(nStates, nFeatures) {}
33  DllExport virtual ~CTrainEdge(void) = default;
34 
43  DllExport static std::shared_ptr<CTrainEdge> create(byte edgeRandomModel, byte nStates, word nFeatures);
53  DllExport virtual void addFeatureVecs(const Mat &featureVector1, byte gt1, const Mat &featureVector2, byte gt2) = 0;
54  DllExport virtual void train(bool doClean = false) {}
65  DllExport Mat getEdgePotentials(const Mat &featureVector1, const Mat &featureVector2, const vec_float_t &vParams, float weight = 1.0f) const;
74  DllExport static Mat getDefaultEdgePotentials(float val, byte nStates) { return getDefaultEdgePotentials(vec_float_t(nStates, val)); }
82  DllExport static Mat getDefaultEdgePotentials(const vec_float_t &values);
83 
84 
85  protected:
97  DllExport virtual Mat calculateEdgePotentials(const Mat &featureVector1, const Mat &featureVector2, const vec_float_t &vParams) const = 0;
98  };
99 }
Mat getEdgePotentials(const Mat &featureVector1, const Mat &featureVector2, const vec_float_t &vParams, float weight=1.0f) const
Returns the edge potential, based on the feature vectors.
Definition: TrainEdge.cpp:29
CTrainEdge(byte nStates, word nFeatures)
Constructor.
Definition: TrainEdge.h:32
Concatenated Model.
Definition: TrainEdge.h:14
virtual Mat calculateEdgePotentials(const Mat &featureVector1, const Mat &featureVector2, const vec_float_t &vParams) const =0
Calculates the edge potential, based on the feature vectors.
Contrast-Sensitive Potts Model.
Definition: TrainEdge.h:12
virtual ~CTrainEdge(void)=default
static std::shared_ptr< CTrainEdge > create(byte edgeRandomModel, byte nStates, word nFeatures)
Factory method returning edge trainer object.
Definition: TrainEdge.cpp:16
Base abstract class for edge potentials training.
Definition: TrainEdge.h:24
Base abstract class for random model training.
virtual void train(bool doClean=false)
Random model training.
Definition: TrainEdge.h:54
EdgeRandomModel
Types of the edge potential finction.
Definition: TrainEdge.h:10
Contrast-Sensitive Potts Model with Prior.
Definition: TrainEdge.h:13
virtual void addFeatureVecs(const Mat &featureVector1, byte gt1, const Mat &featureVector2, byte gt2)=0
Adds a pair of feature vectors.
static Mat getDefaultEdgePotentials(float val, byte nStates)
Returns the data-independent edge potentials.
Definition: TrainEdge.h:74
Interface class for random model training.
Definition: ITrain.h:15