33 ,
CTrainLink(nStatesBase, nStatesOccl, nFeatures)
35 word nStates =
static_cast<word
>(nStatesBase) * static_cast<word>(nStatesOccl);
36 DGM_ASSERT(nStates < 256);
38 m_pTrainer =
new Trainer(static_cast<byte>(nStates), nFeatures);
48 template<
class TrainerParams>
CTrainLinkNested(byte nStatesBase, byte nStatesOccl, word nFeatures, TrainerParams params)
49 :
CTrainLink(nStatesBase, nStatesOccl, nFeatures)
52 word nStates =
static_cast<word
>(nStatesBase) * static_cast<word>(nStatesOccl);
53 DGM_ASSERT(nStates < 256);
55 m_pTrainer =
new Trainer(static_cast<byte>(nStates), nFeatures, params);
65 virtual void save(
const std::string &path,
const std::string &name = std::string(),
short idx = -1)
const {
m_pTrainer->
save(path, name.empty() ?
"CTrainLinkNested" : name, idx); }
66 virtual void load(
const std::string &path,
const std::string &name = std::string(),
short idx = -1) {
m_pTrainer->
load(path, name.empty() ?
"CTrainLinkNested" : name, idx); }
68 virtual void addFeatureVec(
const Mat &featureVector, byte gtb, byte gto)
75 virtual void train(
bool doClean =
false)
80 for (byte i = 0; i < priors.rows; i++)
81 if (priors.at<
float>(i, 0) == 0)
90 DllExport
virtual void saveFile(FILE *pFile)
const {}
91 DllExport
virtual void loadFile(FILE *pFile) {}
113 pRes[gtb] = pot.at<
float>(gt, 0);
CTrainLinkNested(byte nStatesBase, byte nStatesOccl, word nFeatures, TrainerParams params)
Constructor.
virtual Mat calculateLinkPotentials(const Mat &featureVector) const
Returns the data-dependent link (inter-layer edge) potentials.
byte m_nStatesBase
Number of states (classes) at the base layer of ML-CRF.
word getNumFeatures(void) const
Returns number of features.
virtual void save(const std::string &path, const std::string &name=std::string(), short idx=-1) const
Saves the training data.
void addNodeGroundTruth(const Mat >)
Adds ground truth values to the co-occurance histogram vector.
virtual void reset(void)
Resets class variables.
virtual void loadFile(FILE *pFile)
Loads the random model from the file.
Base abstract class for random model training.
virtual void load(const std::string &path, const std::string &name=std::string(), short idx=-1)
Loads the training data.
CTrainLinkNested(byte nStatesBase, byte nStatesOccl, word nFeatures)
Constructor.
CTrainNode * m_pTrainer
Node trainer
Mat getNodePotentials(const Mat &featureVectors, const Mat &weights=Mat(), float Z=0.0f) const
Returns a block of node potentials, based on the block of feature vector.
virtual void load(const std::string &path, const std::string &name=std::string(), short idx=-1)
Loads the training data.
void reset(void)
Resets class variables.
Base abstract class for link (inter-layer edge) potentials training.
Node prior probability estimation class
Mat getPrior(float weight=1.0f) const
Returns the prior probabilies.
virtual void save(const std::string &path, const std::string &name=std::string(), short idx=-1) const
Saves the training data.
Base abstract class for node potentials training.
virtual void reset(void)=0
Resets class variables.
virtual ~CTrainLinkNested(void)
CPriorNode * m_pPrior
Node prior poobability
virtual void saveFile(FILE *pFile) const
Saves the random model into the file.
virtual void addFeatureVec(const Mat &featureVector, byte gt)=0
Adds new feature vector.
Nested link (inter-layer edge) training class.
virtual void train(bool doClean=false)
Random model training.
byte m_nStatesOccl
Number of states (classes) at the occlusion layerts of ML-CRF.
virtual void addFeatureVec(const Mat &featureVector, byte gtb, byte gto)
Adds a feature vector.
virtual void train(bool doClean=false)
Random model training.