在Matlab中使用svmtrain内存不足 [英] Out of memory using svmtrain in Matlab

查看:387
本文介绍了在Matlab中使用svmtrain内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组要尝试使用SVM学习的数据.就上下文而言,数据的维度为35,其中包含大约30'000个数据点.

I have a set of data that I am trying to learn using SVM. For context, the data has a dimensionality of 35 and contains approximately 30'000 data-points.

我以前已经使用该数据集在Matlab中训练了决策树,大约花了20秒.对错误率不完全满意,我决定尝试使用SVM.

I have previously trained decision trees in Matlab with this dataset and it took approximately 20 seconds. Not being totally satisfied with the error rate, I decided to try SVM.

我首先尝试了svmtrain(X,Y).大约5秒钟后,我收到以下消息:

I first tried svmtrain(X,Y). After about 5 seconds, I get the following message:

???在453使用==> svmtrain时出错 计算内核函数时出错: 记不清.输入HELP MEMORY作为您的选项.

??? Error using ==> svmtrain at 453 Error calculating the kernel function: Out of memory. Type HELP MEMORY for your options.

当我查找此错误时,建议我使用 SMO 方法:svmtrain(X, Y, 'method', 'SMO');.大约一分钟后,我得到了:

When I looked up this error, it was suggested to me that I use the SMO method: svmtrain(X, Y, 'method', 'SMO');. After about a minute, I get this:

???在236使用==> seqminopt> seqminoptImpl时出错 在主循环通过的最大次数(15000)内未实现收敛

??? Error using ==> seqminopt>seqminoptImpl at 236 No convergence achieved within maximum number (15000) of main loop passes

==> seqminopt中的错误为100 [alphas offset] = seqminoptImpl(data,targetLabels,...

Error in ==> seqminopt at 100 [alphas offset] = seqminoptImpl(data, targetLabels, ...

==> svmtrain中的错误在437 [alpha bias] = seqminopt(training,groupIndex,...

Error in ==> svmtrain at 437 [alpha bias] = seqminopt(training, groupIndex, ...

我尝试使用其他方法(LS和QP),但又得到了第一个行为:然后延迟5秒

I tried using the other methods (LS and QP), but I get the first behaviour again: 5 second delay then

???在453使用==> svmtrain时出错 计算内核函数时出错: 记不清.输入HELP MEMORY作为您的选项.

??? Error using ==> svmtrain at 453 Error calculating the kernel function: Out of memory. Type HELP MEMORY for your options.

我开始认为我做错了,因为决策树使用起来非常轻松,而在这里,我陷入了看似非常简单的操作.

I'm starting to think that I'm doing something wrong because decision trees were so effortless to use and here I'm getting stuck on what seems like a very simple operation.

非常感谢您的帮助.

推荐答案

您是否已阅读尝试将方法设置为SMO,并使用适合于计算机上可用内存的kernelcachelimit值.

Try setting the method to SMO and use a kernelcachelimit value that is appropriate to the memory you have available on your machine.

在学习期间,该算法将构建大小为kernelcachelimit-by-kernelcachelimit的双精度矩阵.默认值为5000

During learning, the algorithm will build a double matrix of size kernelcachelimit-by-kernelcachelimit. default value is 5000

否则,对您的实例进行子采样,并使用交叉验证之类的技术来衡量分类器的性能.

Otherwise subsample your instances and use techniques like cross-validation to measure the performance of the classifier.

这是相关部分:

内存使用和内存不足错误

将方法"设置为"QP"时,svmtrain函数将在 包含N个元素的数据集,并创建一个(N + 1)×(N + 1)个 矩阵以找到分离的超平面.该矩阵至少需要 8 *(n + 1)^ 2个字节的连续内存.如果这个大小是连续的 内存不可用,软件显示内存不足" 错误消息.

Memory Usage and Out of Memory Error

When you set 'Method' to 'QP', the svmtrain function operates on a data set containing N elements, and it creates an (N+1)-by-(N+1) matrix to find the separating hyperplane. This matrix needs at least 8*(n+1)^2 bytes of contiguous memory. If this size of contiguous memory is not available, the software displays an "out of memory" error message.

将方法"设置为"SMO"(默认)时,内存消耗为 由kernelcachelimit选项控制. SMO算法存储 仅内核矩阵的一个子矩阵,受指定大小的限制 通过kernelcachelimit选项.但是,如果数据点数 超过了kernelcachelimit选项(SMO)指定的大小 算法变慢,因为它必须重新计算内核矩阵 元素.

When you set 'Method' to 'SMO' (default), memory consumption is controlled by the kernelcachelimit option. The SMO algorithm stores only a submatrix of the kernel matrix, limited by the size specified by the kernelcachelimit option. However, if the number of data points exceeds the size specified by the kernelcachelimit option, the SMO algorithm slows down because it has to recalculate the kernel matrix elements.

在大型数据集上使用svmtrain时,如果内存不足或 优化步骤非常耗时,请尝试以下任一方法 以下:

When using svmtrain on large data sets, and you run out of memory or the optimization step is very time consuming, try either of the following:

  • 使用更少的样本并使用交叉验证来测试分类器的性能.

  • Use a smaller number of samples and use cross-validation to test the performance of the classifier.

将方法"设置为"SMO",然后将kernelcachelimit选项设置为系统允许的最大大小.

Set 'Method' to 'SMO', and set the kernelcachelimit option as large as your system permits.

这篇关于在Matlab中使用svmtrain内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆