termination criteria broken if you want to specify number of epochs

asked 2019-02-28 19:30:57 -0600

WreckItTim gravatar image

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?

edit retag flag offensive close merge delete

Comments

Please post an issue.

I can post an issue but it is better if it's you : you will need only a github account

LBerger gravatar imageLBerger ( 2019-03-01 01:49:51 -0600 )edit
1

Thanks, I posted the issue of GitHub!

WreckItTim gravatar imageWreckItTim ( 2019-03-01 12:33:10 -0600 )edit
3

Thanks, I posted the issue on GitHub!

WreckItTim gravatar imageWreckItTim ( 2019-03-01 12:33:18 -0600 )edit