How to resolve out of memory error?

2 views (last 30 days)
I've a problem that occurs when I train the neural network using the code
net = train(net,x,t);
I have got the error "Out of memory. Type HELP MEMORY for your options." Do anybody have idea how to solve this kind of problems?
Thanks
  2 Comments
Greg Heath
Greg Heath on 27 Apr 2013
size(x), size(t), No.of hidden nodes, sample code,...?
Minnu
Minnu on 29 Apr 2013
size(x) is- 830x27
size(t) is- 12x27
no of hidden nodes:20

Sign in to comment.

Accepted Answer

Greg Heath
Greg Heath on 1 May 2013
Unfortunately, your problem is not well posed.
You have 27 I/O pairs. The 27 inputs define, at most, a 26-dim subspace. However, you have 830 "components". You need to transform to a smaller space with at most 26 dimensions.
The simplest way is to use a principal components transformation. You can do this separately or use the PROCESSPCA input processing option of fitnet (regression) or patternnet (classification).
The number of equations that you have is
Neq = prod(size(t)) = 12*17 = 204
With H hidden nodes, the number of unknowns(weights) to estimate are
Nw = (I+1)*H+(H+1)*O
where { I N ] = size(x) and [O N ] = size(t)
If you reduce I to 26,
Nw = O + (I+O+1)*H = 12+39*H
and if you wish to have more equations than unknowns,
H <= Hub = -1 + ceil( Neq-O)/(I+O+1) ) = 4
In addition, if you replace 26 with 830, you see the problem.
Fortunately, there are ways to obtain stable, accurate solutions using a variety of methods. The NNTBX offers validation stopping and objective function regularization. However, with only 27 cases, I don't think you should use any for validation. Therefore,
1. Reduce your input dimensions below 27
help/doc processpca
2. Use the regularization training function 'trainbr'.
help/doc trainbr
3. Search for the minimum H that gives you satisfactory results. 10 different weight initialization trials for each value of H = 1:10 may be sufficient.
4. Once you have determined Hopt, you can obtained less biased performance estimates on nontraining data by using 10 repetitions of 9-fold cross-validation with 24 training cases and 3 testing cases. Although there are 27*26*25 = 17,550 ways that you can choose the 3-member test set, it is hard to believe that 10 repetitions of 9-fold cross-validation won't be more than sufficient.
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (1)

Jan
Jan on 25 Apr 2013
As you will find as answer for dozens or euiqvalent questions in this forum, when you search for them:
  • Install more RAM
  • Close other applications
  • Install even more RAM
  • clear variables, which are not used anymore
  • Use a 64 bit version of OS and Matlab, such that it is useful to:
  • Install much more RAM
  • Increase the virtual memory, when it does not matter if the program need 100 times longer.
  2 Comments
Minnu
Minnu on 29 Apr 2013
When i run my code on laptop ,pc same error occurs .how to resolve it
Jan
Jan on 29 Apr 2013
@Minnu: If I wasn't clear enought already:
Installing more RAM solves the problem, that the installed RAM is exhausted.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!