matlab - 在 Matlab 中使用 svmtrain 内存不足

标签 matlab machine-learning out-of-memory svm convergence

我有一组数据,我正在尝试使用 SVM 来学习。对于上下文,数据的维度为 35,包含大约 30'000 个数据点。

我之前用这个数据集在 Matlab 中训练过决策树,大约花了 20 秒。由于对错误率不太满意,我决定尝试 SVM。

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

??? 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');。大约一分钟后,我得到了这个:

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

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

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

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

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

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

非常感谢您的帮助。

最佳答案

你读过the remarks吗?关于算法内存使用情况快结束了吗?

尝试将方法设置为 SMO 并使用适合您计算机上可用内存的 kernelcachelimit 值。

在学习过程中,算法将构建一个大小为 kernelcachelimit-by-kernelcachelimit 的双矩阵。默认值为 5000

否则,对实例进行二次采样并使用交叉验证等技术来衡量分类器的性能。

以下是相关部分:

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.

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.

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.

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

关于matlab - 在 Matlab 中使用 svmtrain 内存不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15994222/

相关文章:

java - 使用 Jersey 发送大型 JAXB 对象会生成 OutOfMemoryError

matlab - 如何找到Matlab中某个结构体执行的命令?

计算MFCC的MATLAB代码

python - 热修复 Tensorflow 模型未使用 .fit() 在 Eager 模式下运行?

java - Android 内存不足异常存储大量字节

android - 将图像加载到位图对象时出现奇怪的 OutOfMemory 问题

python - 将 Matlab 代码翻译成 Numpy

matlab - 对于类型 'syms' 的输入参数,未定义函数 'char'

python - 即使学习率很小,当类别数量增加时,“模型因损失= NaN而发散”。 [ tensorflow ]

python - 深度学习: Validation Loss Fluctuates Wildly Yet Training Loss is Stable