Error Message when using configured ANN (mismatch number of inputs)

3 vues (au cours des 30 derniers jours)
Léon
Léon le 16 Sep 2011
After creating and storing an ANN in Matlab (ANN Toolbox V 7.0) I tried to compute new predictions using a new set of input observations with:
net(new_obs)
the old Input Matrix was 1511x145, the new one is 100x145, observations are in rows each time. But the error message I get is now:
??? Error using ==> network.sim at 121
Number of inputs does not match net.numInputs.
Error in ==> network.subsref at 14
[v,out2,out3] = sim(vin,subs{:});
In fact, the origin Input matrix does not work with this code either!
I'm wondering if this error corresponds to the type of ANN I'm using since this one is a NARX. But I created a different ANN for a completely different purpose (Pattern Recognition with binary outcome) and there it works at a glance. :-/
Help is greatly appreciated!

Réponse acceptée

Lucas García
Lucas García le 16 Sep 2011
The functions for creating networks in the toolbox will assume that if your input matrix is n x m it will represent m samples of n elements each.
You should present your data to the network as a transposed matrix 145x1511 of your current input matrix when you train the network. The same when you present new inputs to the network, 145x100.
Update
In order to present your input to the network, you can use tonndata in convert your matrix to the standard cell array form. After doing that, the output from tonndata which will be the input to your network, should look like:
[145x1 double] [145x1 double] ... [145x1 double]
1511 times
You should do the same for your targets. Then you can use preparets and train to complete the training process. Once that is done, you should be able to simulate the network, convert to closeloop in order to perform a multi-step-ahead prediction, etc. Notice that you will have to use tonndata again to present new inputs for the simulation process.

Plus de réponses (6)

Tyler Roman
Tyler Roman le 11 Jan 2016
I came across this thread and believe I'm having a very similar issue. I've been able to get an idea of where the problem lies, but it would be helpful to see a full set of code if someone could provide it (The link posted above is no longer valid). I basically have trained a ANN in hopes of using it to fill in some missing data from a time series. I'm able to train it fine but am having trouble getting output when running it on new input data (matrix with 6 columns) to get a single output.

Léon
Léon le 16 Sep 2011
Unfortunately this does not solve the problem since I already told matlab in which direction it will find the time steps in the first place. But I tried to transpose the input and target matrices as you said and re-ran the network. Using net(new_input) afterwards resolves in the same error message. :-(
  1 commentaire
Lucas García
Lucas García le 16 Sep 2011
Can you provide some more info of the architecture of your network? Some code will be helpful to try to understand the problem.

Connectez-vous pour commenter.


Léon
Léon le 17 Sep 2011
No Problem, here is my code so far. Please don't laugh as it is pretty basic as I'm new to matlab and still try to understand it.
The purpose is to create a network that can predict t+5 of the given target time series and is part of my thesis at university.
Thank you very much for helping me!
  1 commentaire
Lucas García
Lucas García le 19 Sep 2011
Hi Léon,
Can't see your code in the link you provided. However, I think it's a matter of how inputs are being presented to the network. I have updated my previous answer trying to be a little more clear.

Connectez-vous pour commenter.


Léon
Léon le 21 Sep 2011
Hi Lucas,
sorry for my late response and thank you very much for helping me!
I totally understand your point, but it does not solve the problem since I tried the ANN from scratch using the simple example data set "simple NARX problem" using the GUI of the toolbox and stored the net afterwards (incl. inputs etc.) Then I tried to generate outputs using this net based on the very same inputs of the example (so I don't even touched the matrices). And the same error occurred! Slowely but surely I think there's something wrong with my matlab installation, isn't it?
  1. Create network "simple NARX problem"
  2. Stored the results and origin matrices
  3. Tried to estimate new outputs using: net(simplenarxInputs)
  1 commentaire
Lucas García
Lucas García le 21 Sep 2011
Hi Léon,
I have been able to access your link and execute your code. And it works fine. I have tried both in MATLAB R2011b and R2010b (which is the one I think you are using).
1. Make sure you clear all your variables before executing your code.
2. Have you changed any MATLAB files in the toolbox? If you have, you probably need to reinstall the toolbox.

Connectez-vous pour commenter.


Léon
Léon le 22 Sep 2011
Hi Lucas,
sorry for bothering you, but one last question:
What command are you using for the NARX?
Because I experience that with simple pattern NN I can create the NN with the example data set implemented (e.g. breast cancer) and then store the matrices afterwards and of course the "net" object.
Now I want to "use" the trained network and I type: "my_output = net(name_of_new_input)" and all "new" outputs are saved in "my_output"
whereas "name_of_new_input" is just the input matrix used to train the network in my case (just to test if the command works).
For NARX (or other timer series NN) this command does not work, so is this working for you? Or how do you "use" the trained NARX in that case?
Thanks again for your time!
Regards
p.s.: I did not change any files or whatsoever :(
  1 commentaire
Lucas García
Lucas García le 22 Sep 2011
I use narxnet for creating the network and then use the net object to do the simulation. Exactly the same that you do for a simple pattern neural network.
Try to execute the code in this link:
http://www.mathworks.es/matlabcentral/answers/14970-neural-network-multi-step-ahead-prediction
The data is available in the toolbox, so you should be able to execute it straight away. Let me know if it works.
If it doesn't then you will have to debug the sim function to try to identify the source of the problem.

Connectez-vous pour commenter.


Léon
Léon le 25 Sep 2011
Hey Lucas thank you very much for your help. You were right, I forgot to prepare the data, hence this works now for me:
% Assumption:
% input_new = new Input Data
% target_new = new Target Data
inputs = tonndata(input_new,false,false);
targets = tonndata(target_new,false,false);
[inputs,inputStates,layerStates,targets] = preparets(net,inputs,{},targets);
output_new = net(inputs,inputStates,layerStates);
error_new = gsubtract(targets,output_new);
performance = perform(net,targets,outputs)
plotresponse(target_neu,output_neu)

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by