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: https://github.com/opencv/opencv/blob...
And in the training loop when deciding to terminate training here: https://github.com/opencv/opencv/blob...
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?
Please post an issue.
I can post an issue but it is better if it's you : you will need only a github account
Thanks, I posted the issue of GitHub!
Thanks, I posted the issue on GitHub!