Got Questions? Get Answers.
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

Thread Subject:
neural network: out of memory error

Subject: neural network: out of memory error

From: pietro

Date: 2 Jan, 2011 17:18:05

Message: 1 of 5

Hi,

I'm using neural network toolbox 7, in particular the tool for predicting time series (ntstool). I have a neural network with 20 neurons, 25 delay, but I get out of memory error. In this link
http://www.mathworks.com/help/toolbox/nnet/backpro6.html
I think the network dimensions are too high for my pc.
I have found that is possible to solve this using this problem throught the setting of parameter net.effficiency.memoryReduction to a value upper than 1. I have tried with the following code, but I get an error.

CODE
% Solve an Input-Output Time-Series Problem with a Time Delay Neural Network
% Script generated by NTSTOOL.
% Created Mon Dec 27 11:25:43 CET 2010
%
% This script assumes these variables are defined:
%
% input - input time series.
% target - target time series.

inputSeries = tonndata(input,false,false);
targetSeries = tonndata(target,false,false);

% Create a Time Delay Network
inputDelays = 0:20;
hiddenLayerSize = 10;
net = timedelaynet(inputDelays,hiddenLayerSize);
net.Efficiency.memoryReduction=2;

% Prepare the Data for Training and Simulation
% The function PREPARETS prepares timeseries data for a particular network,
% shifting time by the minimum amount to fill input states and layer states.
% Using PREPARETS allows you to keep your original time series data unchanged, while
% easily customizing it for networks with differing numbers of delays, with
% open loop or closed loop feedback modes.
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,targetSeries);

% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 80/100;
net.divideParam.valRatio = 10/100;
net.divideParam.testRatio = 10/100;


% Train the Network
[net,tr] = train(net,inputs,targets,inputStates,layerStates);

% Test the Network
outputs = net(inputs,inputStates,layerStates);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)

% View the Network
view(net)

% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
figure, plotresponse(targets,outputs)
figure, ploterrcorr(errors)
figure, plotinerrcorr(inputs,errors)

% Early Prediction Network
% For some applications it helps to get the prediction a timestep early.
% The original network returns predicted y(t+1) at the same time it is given x(t+1).
% For some applications such as decision making, it would help to have predicted
% y(t+1) once x(t) is available, but before the actual y(t+1) occurs.
% The network can be made to return its output a timestep early by removing one delay
% so that its minimal tap delay is now 0 instead of 1. The new network returns the
% same outputs as the original network, but outputs are shifted left one timestep.
nets = removedelay(net);
[xs,xis,ais,ts] = preparets(nets,inputSeries,targetSeries);
ys = nets(xs,xis,ais);
earlyPredictPerformance = perform(net,tc,yc)


ERROR
??? Index exceeds matrix dimensions.

Error in ==> getsamples at 8
  y{j} = x{j}(:,ind);

Error in ==> split_data at 13
  split.Pd = nnfast.getsamples(data.Pd,indices);

Error in ==> perfs_jejj>splitcalc at 40
  split = nntraining.split_data(data,indices);

Error in ==> perfs_jejj at 11
    [trainPerfy,trainN,valPerfy,~,testPerfy,~,JEy,JJy] =
    splitcalc(net,data,fcns);

Error in ==> trainlm>train_network at 199
  [perf,vperf,tperf,je,jj,gradient] = nntraining.perfs_jejj(net,data,fcns);

Error in ==> trainlm at 113
  [net,tr] = train_network(net,tr,data,fcns,param);

Error in ==> network.train at 107
[net,tr] = feval(net.trainFcn,net,X,T,Xi,Ai,EW,net.trainParam);

Error in ==> rete_neurale_simple at 35
[net,tr] = train(net,inputs,targets,inputStates,layerStates);

With net.Efficiency.memoryReduction=1; I don't get this error. What do you suggest me for figuring out the network parameters?
Thanks

Pietro

Subject: neural network: out of memory error

From: Greg Heath

Date: 2 Jan, 2011 19:55:47

Message: 2 of 5

On Jan 2, 12:18 pm, "pietro " <bracard...@email.it> wrote:
> Hi,
>
> I'm using neural network toolbox 7, in particular the tool for predicting time series (ntstool). I have a neural network with 20 neurons, 25 delay, but I get out of memory error. In this linkhttp://www.mathworks.com/help/toolbox/nnet/backpro6.html
> I think the network dimensions are too high for my pc.

In fact, both values may be unnecessarily high for a good
solution to the problem.

See my recent 4 post thread for determining both d (the
number of delays) from the autocorrelation function and
the minimum reasonable value for H (the number of hidden
nodes).

http://groups.google.com/group/comp.soft-sys.matlab/msg/c9643c9642095dd5

Hope this helps.

Greg

Subject: neural network: out of memory error

From: pietro

Date: 3 Jan, 2011 14:33:05

Message: 3 of 5

Greg Heath <heath@alumni.brown.edu> wrote in message <0a4cb41a-3512-4591-a8a6-b573a99ce9d6@p38g2000vbn.googlegroups.com>...
> On Jan 2, 12:18 pm, "pietro " <bracard...@email.it> wrote:
> > Hi,
> >
> > I'm using neural network toolbox 7, in particular the tool for predicting time series (ntstool). I have a neural network with 20 neurons, 25 delay, but I get out of memory error. In this linkhttp://www.mathworks.com/help/toolbox/nnet/backpro6.html
> > I think the network dimensions are too high for my pc.
>
> In fact, both values may be unnecessarily high for a good
> solution to the problem.
>
> See my recent 4 post thread for determining both d (the
> number of delays) from the autocorrelation function and
> the minimum reasonable value for H (the number of hidden
> nodes).
>
> http://groups.google.com/group/comp.soft-sys.matlab/msg/c9643c9642095dd5
>
> Hope this helps.
>
> Greg

Hi Greg,

it is very interesting your post thread, but I have found some difficulties to apply it in my case. I need a neural network for predicting the response of mechanical system, so I have measured the input signal and the output signal and from this I want to estimate the system transfer function. The signal sampling rate is 500Hz. I have triend to use the xcorr like you have mentioned in your example, in this way:

acf = xcorr(input,output);
acfss = acf(N:end)/max(acf);
[maxacf1 d] = max(acfss(2:end))

but I get
maxacf1 =

     1


d =

        1816

What does it mean this delay? I need a neural network with 1816 number of delays?
Moreover I haven't understood the principle ideas for selecting the hidden neurons number. May you give me further explanations?
I hope to have well explained my doubts, if not, don't hesitate to ask me.

Thank you Greg

bye

Pietro

Subject: neural network: out of memory error

From: Greg Heath

Date: 3 Jan, 2011 16:22:44

Message: 4 of 5

On Jan 3, 9:33 am, "pietro " <bracard...@email.it> wrote:
> Greg Heath <he...@alumni.brown.edu> wrote in message <0a4cb41a-3512-4591-a8a6-b573a99ce...@p38g2000vbn.googlegroups.com>...
> > On Jan 2, 12:18 pm, "pietro " <bracard...@email.it> wrote:
> > > Hi,
>
> > > I'm using neural network toolbox 7, in particular the tool for predicting time series (ntstool). I have a neural network with 20 neurons, 25 delay, but I get out of memory error. In this linkhttp://www.mathworks.com/help/toolbox/nnet/backpro6.html
> > > I think the network dimensions are too high for my pc.
>
> > In fact, both values may be unnecessarily high for a good
> > solution to the problem.
>
> > See my recent 4 post thread for determining both d (the
> > number of delays) from the autocorrelation function and
> > the minimum reasonable value for H (the number of hidden
> > nodes).
>
> >http://groups.google.com/group/comp.soft-sys.matlab/msg/c9643c9642095dd5
>
> > Hope this helps.
>
> > Greg
>
> Hi Greg,
>
> it is very interesting your post thread, but I have found some difficulties to apply it in my case. I need a neural network for predicting the response of mechanical system, so I have measured the input signal and the output signal and from this I want to estimate the system transfer function.

Please implement carriage returns so that your paragraphs
are not single lines when cut and pasted into Windows Notepad.

Tranfer functions are only defined for linear systems.
If you have a linear system, you don't need a neural network
model.

So,... I am guessing that you have a nonlinear system and
want to model the I/O characteristics with a NN.


>The signal sampling rate is 500Hz.

Insufficient information. How long is your signal?

>I have triend to use the xcorr like you have mentioned in your example, in this way:
>
> acf = xcorr(input,output);
> acfss = acf(N:end)/max(acf);
> [maxacf1 d] = max(acfss(2:end))
>
> but I get
> maxacf1 =
>
> 1
>
> d =
>
> 1816
>
> What does it mean this delay? I need a neural network with 1816 number of delays?

Insuffient information.

It could indicate periodicity.
What is N?
What does your plot of acfss look like?
Can you post it on a website so I can see it?
Can you send me input and output in a text file?

>
> Moreover I haven't understood the principle ideas for selecting the hidden neurons number. May you give me further explanations?
> I hope to have well explained my doubts, if not, don't hesitate to ask me.

Reference your questions about choosing H
w.r.t. my code statements.

Also search in the CSSM archives using

greg heath Neq Nw

Hope this helps.

Greg

Subject: neural network: out of memory error

From: pietro

Date: 4 Jan, 2011 10:07:04

Message: 5 of 5

Greg Heath <heath@alumni.brown.edu> wrote in message <175cc70a-aeb1-45a2-adee-10e4d29282ad@g26g2000vba.googlegroups.com>...
> On Jan 3, 9:33 am, "pietro " <bracard...@email.it> wrote:
> > Greg Heath <he...@alumni.brown.edu> wrote in message <0a4cb41a-3512-4591-a8a6-b573a99ce...@p38g2000vbn.googlegroups.com>...
> > > On Jan 2, 12:18 pm, "pietro " <bracard...@email.it> wrote:
> > > > Hi,
> >
> > > > I'm using neural network toolbox 7, in particular the tool for predicting time series (ntstool). I have a neural network with 20 neurons, 25 delay, but I get out of memory error. In this linkhttp://www.mathworks.com/help/toolbox/nnet/backpro6.html
> > > > I think the network dimensions are too high for my pc.
> >
> > > In fact, both values may be unnecessarily high for a good
> > > solution to the problem.
> >
> > > See my recent 4 post thread for determining both d (the
> > > number of delays) from the autocorrelation function and
> > > the minimum reasonable value for H (the number of hidden
> > > nodes).
> >
> > >http://groups.google.com/group/comp.soft-sys.matlab/msg/c9643c9642095dd5
> >
> > > Hope this helps.
> >
> > > Greg
> >
> > Hi Greg,
> >
> > it is very interesting your post thread, but I have found some difficulties to apply it in my case. I need a neural network for predicting the response of mechanical system, so I have measured the input signal and the output signal and from this I want to estimate the system transfer function.
>
> Please implement carriage returns so that your paragraphs
> are not single lines when cut and pasted into Windows Notepad.
>
> Tranfer functions are only defined for linear systems.
> If you have a linear system, you don't need a neural network
> model.
>
> So,... I am guessing that you have a nonlinear system and
> want to model the I/O characteristics with a NN.
>
Yes you are on right, sorry for my mistake.

>
> >The signal sampling rate is 500Hz.
>
> Insufficient information. How long is your signal?
>
my signal has 12096 samples

> >I have triend to use the xcorr like you have mentioned in your example, in this way:
> >
> > acf = xcorr(input,output);
> > acfss = acf(N:end)/max(acf);
> > [maxacf1 d] = max(acfss(2:end))
> >
> > but I get
> > maxacf1 =
> >
> > 1
> >
> > d =
> >
> > 1816
> >
> > What does it mean this delay? I need a neural network with 1816 number of delays?
>
> Insuffient information.
>
> It could indicate periodicity.


> What is N?

 12096

> What does your plot of acfss look like?
> Can you post it on a website so I can see it?

In this link, you may find the requested plot:
http://img152.imageshack.us/f/crosscorr.png/
http://img29.imageshack.us/f/inputcorrelation.png/
http://img525.imageshack.us/f/outcorrelation.png/



> Can you send me input and output in a text file?

In this link you may find the input and output signal
http://www.megaupload.com/?d=4WYBJTZN

>
> >
> > Moreover I haven't understood the principle ideas for selecting the hidden neurons number. May you give me further explanations?
> > I hope to have well explained my doubts, if not, don't hesitate to ask me.
>
> Reference your questions about choosing H
> w.r.t. my code statements.
>
> Also search in the CSSM archives using
>
> greg heath Neq Nw
>
> Hope this helps.
>
> Greg
I will try search

I hope to have well explained my doubts, if not, don't hesitate to ask me.


thank you Greg

Pietro

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us