[X,T] = pollution_dataset
net = timedelaynet(1:2,10);
[Xs,Xi,Ai,Ts] = preparets(net,X,T);
net = train(net,Xs,Ts,Xi,Ai);
I used this very simple example code to get a feel; how a time series network predict a future value. So, what I did instead of using 508 dataset for inputs and outputs. I reduced it to 502 dataset and then tried to get 503rd target by using 503rd input vector.
My simple code was
>> d={[80.3800000000000;57.3100000000000;4.34000000000000;1.57000000000000;9.73000000000000;40.0100000000000;6.99000000000000;47.2200000000000]};
>> a=net(d);
This gave me the following results
281.7230 29.0219 157.1554
While actual output should be
149.220000000000
7.88000000000000
73.4600000000000
Why this is giving so deviated values?....Any Explanation Please!
Here is an example I shared sometime earlier. The example predicts 30 steps of a sine wave:
http://www.mathworks.com/matlabcentral/answers/60854#answer_73201
You may use it as a template but that does not mean your network will predict the exact values. You will have to play with the different options before you get your ideal result.
ANN can fit any data. But as I mentioned, you will have to play around with number of neurons, number of layers, different activations functions, performance measures, etc. Unfortunately there isn't a single line answer and you will never get your exact result.
Is there a reason you are using a timedelay network? If you are simple fitting a function why not use fitnet
Sir, I am using narxnet because I have data of 351 days of a company for biogas generation. What I understand that since these are data of different dates. So it is a time series and hence I used timedelay network.
Sir, my main problem is that my training set error is decreasing, but validation set error and test set error stopped decreasing after 2 to 5 iteration. Hence my validation performance is always in 6 digit like 573290.71 or 732357.83 etc.
And since test set performance is of this amount then How can I expect to get a good prediction.
I am playing with different numbers of neurons, layers, divideFcn, training algorithm and so on. But performance always remain in 6 digit!!!
What could I do?
Shashank Sir, How to modify your code When I have 3 dimensional outputs.
newTargetSet = nan(size(newInputSeries))
newTargetSet = num2cell(newTargetSet )
newTargetSet (1:10) = targetSeries(end-9:end)
[xc,xic,aic,tc] = preparets(netc,newInputSeries,{},newTargetSet);
yPredicted = sim(netc,xc,xic,aic)I tried but it gives an error Feedback{1,11} and Feedback{1,1} have different numbers of rows.
I want to get my first element of output and take error.
I wrote code for calculating errors % for 1 dimensional output.
errors1 = gsubtract(yPredicted(1:end-1),toPredict);
errors4=cell2mat(errors1);
errors5=(abs(errors4)./y(321 : end))*100;
How Can I write this for 3 dimensional output. I want %error for output element 1.
Thanking You!
Sandeep
1. You should not use the default divide function DIVIDERAND in a timeseries. Although I recommend DIVIDEBLOCK, DIVIDEIND or DIVIDEINT could also be used.
2. Normalize the target series to have zero mean and unit variance (help zscore)
3. Initialize the RNG before creating the net
4. [ net tr Y Xf Af ] = train(net,Xs,Ts,Xi,Ai);
5. Make sure the design is good
tr = tr
6. If not make multiple designs until you find a good one
7. Make sure the delay buffer is loaded when you run the new data.
Hope this helps.
Thank you for formally accepting my answer
Greg
P.S. Search timedelaynet greg
If you use the command line approach, use that command after the train command which determines tr.
I am already using this command for training.
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
which gives tr as a output.
But I don't know how to exploit tr.
rng(0) [net,tr] = train(net,inputs,targets,inputStates,layerStates); tr = tr % No semicolon
Sir, actually you could not get my point, My question was how to use tr?
For e.g I am getting this.
tr =
trainFcn: 'trainlm'
trainParam: [1x1 nnetParam]
performFcn: 'mse'
performParam: [1x1 nnetParam]
derivFcn: 'defaultderiv'
divideFcn: 'divideint'
divideMode: 'time'
divideParam: [1x1 nnetParam]
trainInd: [1x209 double]
valInd: [1x45 double]
testInd: [1x45 double]
stop: 'Validation stop.'
num_epochs: 8
trainMask: {1x299 cell}
valMask: {1x299 cell}
testMask: {1x299 cell}
best_epoch: 2
goal: 1.0000e-20
states: {'epoch' 'time' 'perf' 'vperf' 'tperf' 'mu' 'gradient' 'val_fail'}
epoch: [0 1 2 3 4 5 6 7 8]
time: [0.5190 1.0380 1.5020 2.4090 3.1940 3.9740 4.7480 5.5590 6.3250]
perf: [3.0733e+06 4.2023e+05 1.1065e+05 1.3808e+04 973.5141 63.4077 0.6065 8.2337e-07 1.4027e-17]
vperf: [1x9 double]
tperf: [1x9 double]
mu: [1x9 double]
gradient: [2.2074e+07 4.1308e+06 2.1810e+06 6.4409e+05 1.4633e+05 2.6902e+04 3.5897e+03 3.1237 1.2626e-05]
val_fail: [0 0 0 1 2 3 4 5 6]
best_perf: 1.1065e+05
best_vperf: 5.5636e+05
best_tperf: 4.1737e+05Now what I suppose to do?
0 Comments