Bad results in modeling systems, with more than 1 Input, using neural network!
Show older comments
I'm getting started with the NN tool box for modeling systems with time delays so I started with an example which goal is to identify the following relation: y(t)=exp(x(t-2))-3*x(t-1).
This is the program I used to find a NN which can simulate the relation y(t) = F( x(t-1), x(t-2) ) :
1. First I create the Input and Output for training
xt=rand(1,100);
for i=3:100 yt(i)=exp(xt(i-2))-3*xt(i-1); end
2. Then I train Hmax*Niter networks
rng(0)
inputSeries = tonndata(xt',false,false);
targetSeries = tonndata(yt',false,false);
Hmax=10;
Niter = 10;
for i = 1:Hmax for j = 1:Niter
inputDelays = 1:2;
hiddenLayerSize = i;
net = timedelaynet(inputDelays,hiddenLayerSize);
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,targetSeries);
net.divideFcn = '';
net.trainFcn = 'trainbr';
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
end
end
3. I select the best network with R2 close to 1.
4. I evaluate the network with unseen data.
xe=rand(1,100);
for i=3:100 ye(i)=exp(xe(i-2))-3*xe(i-1); end
inputSeries = tonndata(xe',false,false);
targetSeries = tonndata(ye',false,false);
[inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,targetSeries);
outputs = net(inputs,inputStates,layerStates);
P=cell2mat(outputs);
O=cell2mat(targets);
plot(P)
hold on
plot(O,'r')
Here is the results: I used 2 for ID because I know it in advance anyway, I found a lot of networks with R2 close to 1, go to the following figure for the training data results.

for unseen data :
xe=3*rand(1,100);
for i=3:100 ye(i)=exp(xe(i-2))-3*xe(i-1); end

for input so large like xe= 5 *rand(1,100) the network model give bad results which is normal.
Unfortunately I can't find the same results when I try to identify the following relation with 2 inputs y(t)=w(t-1)*w(t-2)*exp(x(t-2))-3*x(t-1). In fact for the training data I get R2 close to 1 like the first equation but for unseen data in the same range of the training one ( xe=rand(1,100); we=rand(1,100);) the predicted values don't match the actual ones.
I evaluated the net using
inputSeries = tonndata([xe;we]',false,false);
targetSeries = tonndata(ye',false,false);

I'm sure that if I would identify another equation with more than 2 inputs and outputs I'll have bad results too. Could someone help me with this issue? It would be so helpfull if you post your code which allow you to have good results for more than 1 inputs.
Thanks in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!