Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

termination criteria broken if you want to specify number of epochs

cv::Ptr<cv::ml::ann_mlp> network = cv::ml::ANN_MLP::create(); network->setTermCriteria(cv::TermCriteria(cv::TermCriteria::COUNT, 1000, 0.01); network->train(…);

This should terminate after 1000 epochs no matter what because I specified cv::TermCriteria::COUNT. Not the case. It will terminate based on the default epsilon value.

Problem found in the source code when setting epsilon here:

And in the training loop when deciding to terminate training here:

Only way to do it is specifically set epsilon to 0: network->setTermCriteria(cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 1000, 0);

Which totally nullifies the purpose of cv::TermCriteria::COUNT.

After setting epsilon to 0 the training worked how it was supposed to and terminated only after the specified number of epochs (1000 in this example).

Bug fix please?