Direct Graphical Models  v.1.7.0
TrainLink.cpp
1 #include "TrainLink.h"
2 #include "macroses.h"
3 
4 namespace DirectGraphicalModels
5 {
6  void CTrainLink::addFeatureVec(const Mat &featureVectors, const Mat &gtb, const Mat &gto)
7  {
8  DGM_ASSERT_MSG(featureVectors.channels() == getNumFeatures(), "Number of features in the <featureVectors> (%d) does not correspond to the specified (%d)", featureVectors.channels(), getNumFeatures());
9  DGM_VECTORWISE2<CTrainLink, &CTrainLink::addFeatureVec>(*this, featureVectors, gtb, gto);
10  }
11 
12  void CTrainLink::addFeatureVec(const vec_mat_t &featureVectors, const Mat &gtb, const Mat &gto)
13  {
14  DGM_ASSERT_MSG(featureVectors.size() == getNumFeatures(), "Number of features in the <featureVectors> (%zu) does not correspond to the specified (%d)", featureVectors.size(), getNumFeatures());
15  DGM_VECTORWISE2<CTrainLink, &CTrainLink::addFeatureVec>(*this, featureVectors, gtb, gto);
16  }
17 
18  Mat CTrainLink::getLinkPotentials(const Mat &featureVector, float weight) const
19  {
20  Mat res = calculateLinkPotentials(featureVector);
21  if (weight != 1.0) pow(res, weight, res);
22  return res;
23  }
24 
25 }
void addFeatureVec(const Mat &featureVectors, const Mat &gtb, const Mat &gto)
Adds a block of new feature vectors.
Definition: TrainLink.cpp:6
word getNumFeatures(void) const
Returns number of features.
Definition: ITrain.h:37
Mat getLinkPotentials(const Mat &featureVector, float weight=1.0f) const
Returns the link potential, based on the feature vector.
Definition: TrainLink.cpp:18
virtual Mat calculateLinkPotentials(const Mat &featureVector) const =0
Calculates the link potential, based on the feature vector.