Why does data prediction with cascade forward net not work ?

1 次查看(过去 30 天)
I have a problem with making new predictions with my cascade forward net. i created a cascade forward net with 10 Neurons and trained it. Then I tried to make predictions with new data by using sim(net,Xnew) which always gives the same error saying:
Error using network/sim (line 266)
Input data sizes do not match net.inputs{1}.size.
Error in CASCADEnet (line 12)
predCASCADE=sim(netCASCADE,Xnew');
Xnew vector and X vector (with which I trained the net) have the same size. This is my Code so far with X as input and Y as Target vector:
netCASCADE=cascadeforwardnet(10,'trainlm');
netCASCADE.divideParam.trainRatio=0.7;
netCASCADE.divideParam.valRatio=0.15;
netCASCADE.divideParam.testRatio=0.15;
netCASCADE=train(netCASCADE, X',Y');
predCASCADE=sim(netCASCADE,Xnew');
Thanks in advance for help !

回答(1 个)

Nachiket Katakkar
Nachiket Katakkar 2017-2-23
This error message is observed if the number of columns (input size) in the Test data (Xnew) does not match the number of columns in the Train data (X). I would recommend ensuring that the number of columns in Xnew and X are exactly the same:
>> isequal(size(Xnew,2),size(X,2))
Here is an example with a data-set containing 2 columns and using your code:
load carsmall
X = [Weight,Acceleration];
Y = MPG;
Xnew = X;
netCASCADE=cascadeforwardnet(10,'trainlm');
netCASCADE.divideParam.trainRatio=0.7;
netCASCADE.divideParam.valRatio=0.15;
netCASCADE.divideParam.testRatio=0.15;
netCASCADE=train(netCASCADE, X',Y');
predCASCADE=sim(netCASCADE,Xnew')

Community Treasure Hunt

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

Start Hunting!

Translated by