Sofiane
Sofiane

Reputation: 67

LS-SVM training : Out of memory

I try to train an LS-SVM classifier on a dataset having the following size:

Training dataset: TS = 48000x12 (double)
Groups: G = 48000x1 (double)

Matlab training code is:

class = svmtrain(TS,G,'method','LS',...
                 'kernel_function','rbf','boxconstraint',C,'rbf_sigma',sigma);

Then, I got this error message:

Error using svmtrain (line 516)
Error evaluating kernel function 'rbf_kernel'.

Caused by:
Error using repmat
Out of memory. Type HELP MEMORY for your options.

Note that the size of the physical memory is 4Gb, and it works when I decrease dataset training size. So if there are any solution with the same data size and of course without adding physical memory.

Upvotes: 1

Views: 1384

Answers (1)

lejlot
lejlot

Reputation: 66815

It seems, that the implementation requires computation of the whole Gram matrix, which is the size of N x N (where N - number of sampels) in your case it is 2,304,000,000, now each is represented by the 32bit float, meaning it requires at least 4 bytes which gives as 9,216,000,000 bytes required, which is roughly 9GB of data just for a Gram (Kernel) matrix.

There are two options:

  • Find implementation which for RBF kernel do not compute the kernel (Gram) matrix, but instead use some callable to compute the kernel value each time
  • You can try to use some kind of LS-SVM approximation, like Fast Sparse Approximation of Least Squares Support Vector Machine : http://homes.cs.washington.edu/~lfb/software/FSALS-SVM.htm

Upvotes: 1

Related Questions