Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to solve out of memory errors in Matlab Neural Networks toolbox for large datasets?

Asked by mmenvo

mmenvo (view profile)

on 4 Oct 2012

Hi all,

I have huge input datasets to use in NN Toolbox, but i can't use more than 20 hidden neurons because toolbox shows out of memory errors. It shows like this:

??? Error using ==> horzcat

Out of memory. Type HELP MEMORY for your options.

Error in ==> C:\Program Files\MATLAB\R2010b\toolbox\nnet\nnutils\+nnprop\jac_s.p>jac_s at 285

How to solve this problem, I hope somebody will help me out of this problem.


Here is my code that i used:


EX_355 = xlsread('(10nm-50nm).xlsx','A2:A165238');

EX_532 = xlsread('(10nm-50nm).xlsx','B2:B165238');

BA_355 = xlsread('(10nm-50nm).xlsx','C2:C165238');

BA_532 = xlsread('(10nm-50nm).xlsx','D2:D165238');

BA_1064 = xlsread('(10nm-50nm).xlsx','E2:E165238');

Reff = xlsread('(10nm-50nm).xlsx','F2:F165238');

Input(1,:) = EX_355;

Input(2,:) = EX_532;

Input(3,:) = BA_355;

Input(4,:) = BA_532;

Input(5,:) = BA_1064;

Target(1,:) = Reff;

net = feedforwardnet;

net = configure(net,Input,Target);

net = init(net);

inputs = Input;

targets = Target;

hiddenLayerSize = 21;

net = fitnet(hiddenLayerSize);

net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};

net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};

net.divideFcn = 'dividerand';

net.divideMode = 'sample';

net.divideParam.trainRatio = 10/100;

net.divideParam.valRatio = 45/100;

net.divideParam.testRatio = 45/100;

net.trainFcn = 'trainlm';

net.performFcn = 'mse';

net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'};

[net,tr] = train(net,inputs,targets);

outputs = net(inputs);

errors = gsubtract(targets,outputs);

performance = perform(net,targets,outputs)

trainTargets = targets .* tr.trainMask{1};

valTargets = targets .* tr.valMask{1};

testTargets = targets .* tr.testMask{1};







1 Comment


mmenvo (view profile)

on 4 Oct 2012

My laptop ram is 2.93 GB (showing in the PC) even though it is 8 GB ram and running on 32 bit windows 7 OS.


mmenvo (view profile)


No products are associated with this question.

1 Answer

Answer by Jason Ross

Jason Ross (view profile)

on 4 Oct 2012
Edited by Jason Ross

Jason Ross (view profile)

on 4 Oct 2012

If you are running a 32-bit OS, you won't be able to access more than 4 GB RAM. You will need to install a 64-bit version of Windows (and MATLAB) to access all 8 GB in your machine.


Jason Ross

Jason Ross (view profile)

Contact us