Direct Graphical Models
v.1.7.0
|
Nested link (inter-layer edge) training class. More...
#include <TrainLinkNested.h>
Public Member Functions | |
CTrainLinkNested (byte nStatesBase, byte nStatesOccl, word nFeatures) | |
Constructor. More... | |
template<class TrainerParams > | |
CTrainLinkNested (byte nStatesBase, byte nStatesOccl, word nFeatures, TrainerParams params) | |
Constructor. More... | |
virtual | ~CTrainLinkNested (void) |
virtual void | reset (void) |
Resets class variables. More... | |
virtual void | save (const std::string &path, const std::string &name=std::string(), short idx=-1) const |
Saves the training data. More... | |
virtual void | load (const std::string &path, const std::string &name=std::string(), short idx=-1) |
Loads the training data. More... | |
virtual void | addFeatureVec (const Mat &featureVector, byte gtb, byte gto) |
Adds a feature vector. More... | |
virtual void | train (bool doClean=false) |
Random model training. More... | |
Public Member Functions inherited from DirectGraphicalModels::CTrainLink | |
CTrainLink (byte nStatesBase, byte nStatesOccl, word nFeatures) | |
Constructor. More... | |
virtual | ~CTrainLink (void)=default |
void | addFeatureVec (const Mat &featureVectors, const Mat >b, const Mat >o) |
Adds a block of new feature vectors. More... | |
void | addFeatureVec (const vec_mat_t &featureVectors, const Mat >b, const Mat >o) |
Adds a block of new feature vectors. More... | |
Mat | getLinkPotentials (const Mat &featureVector, float weight=1.0f) const |
Returns the link potential, based on the feature vector. More... | |
Public Member Functions inherited from DirectGraphicalModels::ITrain | |
ITrain (byte nStates, word nFeatures) | |
Constructor. More... | |
virtual | ~ITrain (void)=default |
word | getNumFeatures (void) const |
Returns number of features. More... | |
Public Member Functions inherited from DirectGraphicalModels::CBaseRandomModel | |
CBaseRandomModel (byte nStates) | |
Constructor. More... | |
virtual | ~CBaseRandomModel (void) |
byte | getNumStates (void) const |
Returns number of states (classes) More... | |
Protected Member Functions | |
virtual void | saveFile (FILE *pFile) const |
Saves the random model into the file. More... | |
virtual void | loadFile (FILE *pFile) |
Loads the random model from the file. More... | |
virtual Mat | calculateLinkPotentials (const Mat &featureVector) const |
Returns the data-dependent link (inter-layer edge) potentials. More... | |
Protected Member Functions inherited from DirectGraphicalModels::CBaseRandomModel | |
std::string | generateFileName (const std::string &path, const std::string &name, short idx) const |
Generates name of the data file for storing random model parameters. More... | |
Private Attributes | |
CPriorNode * | m_pPrior |
Node prior poobability More... | |
CTrainNode * | m_pTrainer |
Node trainer More... | |
Additional Inherited Members | |
Protected Attributes inherited from DirectGraphicalModels::CTrainLink | |
byte | m_nStatesBase |
Number of states (classes) at the base layer of ML-CRF. More... | |
byte | m_nStatesOccl |
Number of states (classes) at the occlusion layerts of ML-CRF. More... | |
Protected Attributes inherited from DirectGraphicalModels::CBaseRandomModel | |
byte | m_nStates |
The number of states (classes) More... | |
Nested link (inter-layer edge) training class.
This class in order to estimate edge potentials, uses an unary potential trainer, which is learned for nStatesBase \(\times\) nStatesOccl states (classes), corresponding to the base and occlusion layers of the graphical model.
Trainer | The nested node potential trainer, derived from the CTrainNode class |
Definition at line 21 of file TrainLinkNested.h.
|
inline |
Constructor.
nStatesBase | Number of states (classes) for the base layer of the graphical model |
nStatesOccl | Number of states (classes) for the occlusion layer of the graphical model
|
nFeatures | Number of features |
Definition at line 31 of file TrainLinkNested.h.
|
inline |
Constructor.
TrainerParams | Type of the parameters to the nested node potential trainer |
nStatesBase | Number of states (classes) for the base layer of the graphical model |
nStatesOccl | Number of states (classes) for the occlusion layer of the graphical model |
nFeatures | Number of features |
params | Parameters of the nested node potential trainer |
Definition at line 48 of file TrainLinkNested.h.
|
inlinevirtual |
Definition at line 58 of file TrainLinkNested.h.
|
inlinevirtual |
Adds a feature vector.
Used to add featureVector, corresponding to the ground-truth states (classes) gtb and gto for training. Here the couple {gtb, gto} corresponds to the nodes from base aod occlusion layers.
featureVector | Multi-dimensinal point: Mat(size: nFeatures x 1; type: CV_8UC1), corresponding to both nodes of the link. |
gtb | The ground-truth state (class) of the first node of the edge, corresponding to the base layer |
gto | The ground-truth state (class) of the second node of the edge, corresponding to the occlusion layer |
Implements DirectGraphicalModels::CTrainLink.
Definition at line 68 of file TrainLinkNested.h.
|
inlineprotectedvirtual |
Returns the data-dependent link (inter-layer edge) potentials.
This function returns edge potential matrix, which elements are obrained from the unary potential vector:
\[ edgePot[nStatesBase:nStates][0:nStatesBase] = nodePot[nStatesBase \times nStatesOccl] = f(\textbf{f}[nFeatures]). \]
Here \( nStates = nStatesBase + nStatesOccl\).
featureVector | Multi-dimensinal point \(\textbf{f}\): Mat(size: nFeatures x 1; type: CV_8UC1), corresponding to the data site of the both edge nodes |
Implements DirectGraphicalModels::CTrainLink.
Definition at line 100 of file TrainLinkNested.h.
|
inlinevirtual |
Loads the training data.
Allows to re-use the class. Loads data to the file: "<path><name>_<idx>.dat".
path | Path to the folder, containing the data file. |
name | Name of data file. If empty, will be generated automatically from the class name. |
idx | Index of the data file. Negative value means no index. |
Reimplemented from DirectGraphicalModels::CBaseRandomModel.
Definition at line 66 of file TrainLinkNested.h.
|
inlineprotectedvirtual |
Loads the random model from the file.
Allows to re-use the class.
pFile | Pointer to the file, opened for reading. |
Implements DirectGraphicalModels::CBaseRandomModel.
Definition at line 91 of file TrainLinkNested.h.
|
inlinevirtual |
Resets class variables.
Allows to re-use the class.
Implements DirectGraphicalModels::CBaseRandomModel.
Definition at line 64 of file TrainLinkNested.h.
|
inlinevirtual |
Saves the training data.
Allows to re-use the class. Stores data to the file: "<path><name>_<idx>.dat".
path | Path to the destination folder. |
name | Name of data file. If empty, will be generated automatically from the class name. |
idx | Index of the destination file. Negative value means no index. |
Reimplemented from DirectGraphicalModels::CBaseRandomModel.
Definition at line 65 of file TrainLinkNested.h.
|
inlineprotectedvirtual |
Saves the random model into the file.
Allows to re-use the class.
pFile | Pointer to the file, opened for writing. |
Implements DirectGraphicalModels::CBaseRandomModel.
Definition at line 90 of file TrainLinkNested.h.
|
inlinevirtual |
Random model training.
Auxilary function for training - some derived classes may use this function inbetween training and classification phases
doClean | Flag indicating if the memory, keeping the trining data should be released after training |
Reimplemented from DirectGraphicalModels::CTrainLink.
Definition at line 75 of file TrainLinkNested.h.
|
private |
Node prior poobability
Definition at line 124 of file TrainLinkNested.h.
|
private |
Node trainer
Definition at line 125 of file TrainLinkNested.h.