Neural Network Toolbox Example Dataset Error - Index Exceeds Matrix Dimensions

8 views (last 30 days)
I am trying to learn how to use the neural network toolbox and thought that the best way to do that would be to work through the examples in the first section of the toolbox documentation (i.e. "Getting Started"). However, with the exception of the simplefit dataset, every time I try to use one of the given data sets, Matlab returns "Index Exceeds Matrix Dimensions."
For example, if done in the command-line, this is what it looks like:
>> load house_dataset
>> net=newfit(houseInputs,houseTargets,20);
??? Index exceeds matrix dimensions.
Error in ==> initnw at 113 range(inputStart(j):inputStop(j),:) = temp((inputStart(j):inputStop(j))-inputStart(j)+1,:);
Error in ==> initlay at 73 net = feval(initFcn,net,i);
Error in ==> network.init at 68 net = feval(initFcn,net);
Error in ==> newff>new_5p1 at 188 net = init(net);
Error in ==> newff at 89 net = new_5p1(varargin{:});
Error in ==> newfit at 67 net = newff(varargin{:});
These are exactly the same commands that are given in the documentation (under "Fitting a Function" and then "Using Command-Line Functions").
If I try to access the data using the neural networking GUI, the error message comes up in between the Network Size and Train Network steps. Everything I've done has been exactly how the manual describes; these examples are basic enough that there doesn't seem to be much I could have done to mess it up. I've tried the function fitting, pattern recognition, and clustering examples and they've all failed in the same way.
Could someone who understands the programming of the toolbox explain why this error is coming up here and what I can try to fix it?

Accepted Answer

Greg Heath
Greg Heath on 1 May 2013
I do not have this problem. Try clearing the workspace and check after loading
clear all, clc;
load house_dataset;
whos
net=newfit(houseInputs,houseTargets,20);
whos
Hope this helps.
Greg
  1 Comment
Jonathan Walter
Jonathan Walter on 24 Sep 2015
I am having a similar issue, when I run both fit_house_demo" and the "accepted" answer above from Geg (Matlab 2013b).
: Index exceeds matrix dimensions. Error in initnw>initialize_layer (line 169) range(inputStart(j):inputStop(j),:) = temp2((inputStart(j):inputStop(j))-inputStart(j)+1,:); Error in initnw (line 94) out1 = initialize_layer(in1,in2); Error in initlay>initialize_network (line 148) net = feval(initFcn,net,i); Error in initlay (line 90) out1 = initialize_network(in1); Error in network/init (line 33) net = feval(initFcn,net); Error in newff>new_5p1 (line 236) net = init(net); Error in newff>create_network (line 130) net = new_5p1(varargin{:}); Error in newff (line 102) out1 = create_network(varargin{:}); Error in newfit>create_network (line 98) net = newff(varargin{:}); Error in newfit (line 79) out1 = create_network(varargin{:});

Sign in to comment.

More Answers (2)

Orlando Stein Junior
Orlando Stein Junior on 20 Jun 2016
Guys, I am using R2016a for mac and have the same problem.
>> load house_dataset; >> whos Name Size Bytes Class Attributes
houseInputs 13x506 52624 double
houseTargets 1x506 4048 double
>> net=newfit(houseInputs, houseTargets, 20); Index exceeds matrix dimensions. Error in initnw>initialize_layer (line 168) range(inputStart(j):inputStop(j),:) = temp2((inputStart(j):inputStop(j))-inputStart(j)+1,:); Error in initnw (line 93) out1 = initialize_layer(in1,in2); Error in initlay>initialize_network (line 147) net = feval(initFcn,net,i); Error in initlay (line 89) out1 = initialize_network(in1); Error in network/init (line 32) net = feval(initFcn,net); Error in newff>new_5p1 (line 235) net = init(net); Error in newff>create_network (line 129) net = new_5p1(varargin{:}); Error in newff (line 101) out1 = create_network(varargin{:}); Error in newfit>create_network (line 98) net = newff(varargin{:}); Error in newfit (line 79) out1 = create_network(varargin{:}); >>
Can you help me?

Hugh Nolan
Hugh Nolan on 30 Mar 2017
Edited: Hugh Nolan on 30 Mar 2017
Hi all, I have just solved this issue on a few of my PCs. The issue was that a file in my "m files" directory (which I sync across PCs with dropbox) was shadowing a file called during the training processing, setting up some variables incorrectly for initnw. In my case, it was "minmax.m" which was shadowing an internal function in the neural network toolbox. However, yours may be different, so my general steps for finding this were as follows:
  • I used "procmon.exe" from Sysinternals to track down the file shadowing.
  • I set up a filter in Procmon to include only files from my "m files" directory (if Path excludes "C:\m files" then Exclude)
  • I did "clear all" to force Matlab to reload any M-file into memory, forcing a disk read which will be picked up by procmon.
  • I loaded the test dataset , and initialised the network variable
  • I then began capturing events in procmon
  • Then I called train and got my error in initnw
  • I stopped capturing in procmon, then looked for any file reads in my "m files" directoy - only one "single file" read was performed (the rest were directory scans) - this was minmax.m
  • Renaming minmax then allowed me to use train properly.
Hope that is of some help in the future!
  3 Comments
David Holl
David Holl on 28 Oct 2019
Thank you very much, Hugh! I had a function minmax.m in my custom matlab path. Removing this file did the trick for me.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!