9 class CSamplesAccumulator;
22 TrainNodeCvANNParams(word _numLayers,
double _weightScale,
double _momentumScale,
int _maxCount,
double _epsilon,
int _term_criteria_type,
int _maxSamples) :
numLayers(_numLayers),
weightScale(_weightScale),
maxCount(_maxCount),
epsilon(_epsilon),
term_criteria_type(_term_criteria_type),
maxSamples(_maxSamples) {}
31 TermCriteria::MAX_ITER | TermCriteria::EPS,
59 DllExport
CTrainNodeCvANN(byte nStates, word nFeatures,
size_t maxSamples);
62 DllExport
void reset(
void);
63 DllExport
void save(
const std::string &path,
const std::string &name = std::string(),
short idx = -1)
const;
64 DllExport
void load(
const std::string &path,
const std::string &name = std::string(),
short idx = -1);
66 DllExport
void addFeatureVec(
const Mat &featureVector, byte gt);
68 DllExport
void train(
bool doClean =
false);
Ptr< ml::ANN_MLP > m_pANN
Artificial Neural Network.
int term_criteria_type
Termination cirteria type (according the the two previous parameters)
void init(TrainNodeCvANNParams params)
double weightScale
Strength of the weight gradient term. The recommended value is about 0.1. Default value is 0...
void train(bool doClean=false)
Random model training.
void calculateNodePotentials(const Mat &featureVector, Mat &potential, Mat &mask) const
Calculates the node potential, based on the feature vector.
double epsilon
The desired accuracy or change in parameters at which the iterative algorithm stops.
const TrainNodeCvANNParams TRAIN_NODE_CV_ANN_PARAMS_DEFAULT
CSamplesAccumulator * m_pSamplesAcc
Samples Accumulator.
OpenCV Artificial neural network parameters.
void loadFile(FILE *pFile)
Loads the random model from the file.
TrainNodeCvANNParams(word _numLayers, double _weightScale, double _momentumScale, int _maxCount, double _epsilon, int _term_criteria_type, int _maxSamples)
void addFeatureVec(const Mat &featureVector, byte gt)
Adds new feature vector.
Samples accumulator abstract class.
int maxCount
The maximum number of iterations (time / accuracy)
virtual ~CTrainNodeCvANN(void)
void load(const std::string &path, const std::string &name=std::string(), short idx=-1)
Loads the training data.
Base abstract class for node potentials training.
void reset(void)
Resets class variables.
word numLayers
Number of layers of neurons.
void saveFile(FILE *pFile) const
Saves the random model into the file.
struct DirectGraphicalModels::TrainNodeCvANNParams TrainNodeCvANNParams
OpenCV Artificial neural network parameters.
OpenCV Artificial neural network training class.
CTrainNodeCvANN(byte nStates, word nFeatures, TrainNodeCvANNParams params=TRAIN_NODE_CV_ANN_PARAMS_DEFAULT)
Constructor.
double momentumScale
Strength of the momentum term (the difference between weights on the 2 previous iterations). This parameter provides some inertia to smooth the random fluctuations of the weights. It can vary from 0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough. Default value is 0.1.
void save(const std::string &path, const std::string &name=std::string(), short idx=-1) const
Saves the training data.
size_t maxSamples
Maximum number of samples to be used in training. 0 means using all the samples.