Matlab中对svmtrain迭代次数MaxIter的设置

本文探讨了在使用Matlab自带函数svmtrain进行二维分类器训练时遇到的迭代次数限制问题,提供了调整迭代次数的方法,并分享了解决方案及实际应用案例。

在使用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


转自:http://blog.youkuaiyun.com/amazingjack/article/details/27083103


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值