Reputation: 562
I am trying to perform PCA on the MNIST data set. I have the following code so far.
...load data into MATLAB
% Centre data matrix
imagesMean = mean(images);
imagesShifted = images - imagesMean;
% Compute covariance matrix of mean shifted images
covariance = cov(imagesShifted);
Trying to do this gives me the following response:
Out of memory. Type "help memory" for your options.
Error in cov (line 155) c = (xc' * xc) ./ denom;
Error in PCA (line 27) covariance = cov(imagesShifted);
imagesShifted
is a 784x60000 double matrix.
I am using a MacBook Pro 2015 with 16GB RAM and a 2.8 GHz processor and a dedicated graphics card.
I looked under the help menu for the memory command but the information only seems relevant to Windows machines. Also looked at the MathWorks website for resolving out of memory issues but wasn't sure how to proceed based on that information.
How can I get around this issue?
Upvotes: 0
Views: 111
Reputation: 61
For large data sets, I suggest you to use the princomp function of matlab, with the flag 'econ' activated.
https://es.mathworks.com/help/stats/princomp.html
Or the pca function with the flag 'economy' or indicating the 'NumComponents' you wish.
https://es.mathworks.com/help/stats/pca.html
Upvotes: 1