I’ve written a Matlab script for classification. When I execute this I’m getting Out Of Memory error.
for i =1:size(Y)
if(predictions(i) ~= clasL(find(ismember(mydata,X(i)),'rows')))
error = error+1;
end
end
In the above code Y and predictions are vectors of dimension 19928. And mydata and X are 19928*62061 and 12819*62061 matrices. When I execute the following code I’m getting the following error
Error using ==
Out of memory. Type HELP MEMORY for your options.
Error in ismember (line 62)
tf = (a == s);
Error in myinit (line 105)
if(predictions(i) ~= clasL(find(ismember(mydata,X(i)),1)))
How to overcome this? Please help me.
Thanks
First try running ulimit on the MATLAB process so it can use as much memory as is available.
Second, I think you want to switch the order of arguments to
ismember:Third, you don’t need the extra
findfunction if you change the order of arguments. You would then simply do this (inside the loop):Fourth, to save on time, you can run
ismemberjust once for all the rows inX(no loop) and then find the number of errors in a vectorized manner: