我是靠谱客的博主 火星上保温杯,最近开发中收集的这篇文章主要介绍matlab中增大迭代次数,Matlab中对svmtrain迭代次数MaxIter的设置,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

在使用Matlab自带函数svmtrain进行训练二维分类器时,得到了如下的错误提示:

Unable to solve the optimization problem: Maximum number of iterations exceeded; increase options.MaxIter. To continue solving the problem with the current solution as the starting point, set x0 = x before calling quadprog.

意思就是:在默认的最大爹地次数中,不能拟合数据。

我查了一下文档发现有默认迭代次数默认的最大值是15000次,个人感觉这个次数能够应付绝大多数情况,如果到了这个次数还没有得到结果,建议还是在训练样本的选择上下点功夫吧。一个好的样本,即使数据量有一万,用SVM训练也不过几秒钟;相反,如果数据交叉错综复杂,即使500个数据也会计算很久也得不到结果。原话如下:

'options' MaxIter   Integer that specifies the maximum number of iterations of the main loop. If this limit is exceeded before the algorithm converges, then the algorithm stops and returns an error. Default is 15000.

看到这里,一个直观的想法就是增大迭代次数,可是进入工具箱函数源代码来修改很麻烦,能不能像svmtrain的其他接口(比如核函数)那样进行设置呢?答案是肯定的,设置方法如下:

option = statset(‘MaxIter’,30000); % 设置迭代次数为30000

svmStruct = svmtrain( Training, Group, 'Kernel_Function', 'rbf', 'quadprog_opts', option );

或者使用第二种方法:

option = optimset(‘MaxIter’,30000); % 设置迭代次数为30000

svmStruct = svmtrain( Training, Group, 'Kernel_Function', 'rbf', 'quadprog_opts', option );

在寻找解决方法的时候,我发现pengyanyan和Vivek两位小伙伴也遇到了这个问题,在不同的论坛提问,这里附上地址:

http://stackoverflow.com/questions/6560031/svmtrain-unable-to-solve-the-optimization-problem

http://www.ilovematlab.cn/thread-252606-1-1.html

最后

以上就是火星上保温杯为你收集整理的matlab中增大迭代次数,Matlab中对svmtrain迭代次数MaxIter的设置的全部内容,希望文章能够帮你解决matlab中增大迭代次数,Matlab中对svmtrain迭代次数MaxIter的设置所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(73)

评论列表共有 0 条评论

立即
投稿
返回
顶部