Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: POLLUTION MORTALITY : Response to a comment in ANSWERS
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Greg Heath

Posts: 5,871
Registered: 12/7/04
POLLUTION MORTALITY : Response to a comment in ANSWERS
Posted: Aug 16, 2013 9:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have a bug and cannot ANSWERS. Therefore I will respond to the last author comment in ANSWERS below:

Time series in Artificial neural network (ANN) example pollution
Mortality Asked by sandeep on 27 Jul 2013 at 6:33
Comment by Greg Heath on 12 Aug 2013 at 15:00
% 1. net = net will show you all of the net properties
% 2. tr = tr will show you the training record
% 3. tr.divideint, tr.trainInd ,etc indicate that you do not have
% uniform spacing between your points. Why didn't you follow my
% recommendation?
% 4. Why don't you use dividetrain first and concentrate on mini-
% mizing the No. of hidden neurons you need to get a good design.
% 5. goal = 1e-20 is unreasonable. Try 0.01*mean(var(target',1)) to
% get a normalized MSE of 0.01
% 6. Try 10 different random weight initializations for each value of
% hidden nodes that you try.
% 7. If you search on rng(0) timedelaynet you will probably find some
% helpful code
% 8. Also search on h = Hmin

Response by sandeep on 14 Jul 2013 ~9:30
% Which recommendation I did not follows? for divideblock? I used
% that one but it did not give good results.

Divideblock is not the reason for the failure. However, If you try
another option, you MUST maintain the same uniform time spacing
for trn/val and tst.

% Please explain your point no. 6. " Try 10 different random weight
% initializations for each value of hidden nodes that you try."

Assumes prob(successful random weight initialization) >= 10%

I have many posts as examples. Search on i = 1:Ntrials

% Suppose I get good results after 8 time training. But again when
% I want to reproduce the results I could not get the same results.
% If I use rng(0) then I get constant results after second training.
% How could I reproduce my results which is best? rng(0)
% reproduce the results but it is worse than other results.

1. You can record the initial state of the RNG before each
weight initialization,

help rng

Ntrials= 5
for i = 1:Ntrials
state(i) = rng
output(i) = rand
% To recalculate output(3)
rng( state(3))
y = rand
error = output(3)-y %0

2. Or, within a loop, store the net that has the current best
performance on the validation data.

% Here is my code
% %A 4 dimensional input, having data of 351 days
% filename = 'Inputs_2013_new.xlsx';
% u= xlsread(filename);
% % A 1 dimensional output, having datas of 351 days.
% filename = 'Outputs_2013_new.xlsx';

I'm confused: For pollution_dataset
size(input) = [8 508]
size(output) = [ 3 508]

Which ones are you using?

% y= xlsread(filename);
% x = tonndata(u,true,false);
% t = tonndata(y,true,false);
% inputSeries = x(1:320); %320 days for training
% xnh=x(321:end); %31 days for prediction of outputs
% targetSeries = t(1:320);
% toPredict = t(321 : end);

BASIC ERROR: Input is 4-D but you are using a 1-D notation!

% inputDelays = 1:21;
% feedbackDelays = 1:21;


% hiddenLayerSize = [25 15];

Why TWO hidden??? Why these values?

% net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
% net.layers{1}.transferFcn='logsig';
% net.layers{2}.transferFcn='logsig';

Innappropriate for mapminmax

% net.layers{1}.initFcn='initnw';
% net.layers{2}.initFcn='initnw';
% net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
% net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};

DELETE previous 4. They are defaults

% [inputs,inputStates,layerStates,targets] = preparets(net,inputSeries,{},targetSeries);
% net.divideFcn = 'dividetrain'; %I tried with dividerand, divideblock, divideint,
% no one is giving correct results

Dividetrain useful for determining delays and hidden nodes. Then
retrain with divideblock to get unbiased performance estimates from
nontraining test set

%net.divideParam.trainRatio = 70/100;
%net.divideParam.valRatio = 15/100;
%net.divideParam.testRatio = 15/100;

DELETE. Incompatible with dividetrain

% net.trainFcn = 'trainlm'; %I tried diffrent training algorithm, But could
% not get better predition.
% net.performFcn = 'mse';
% net.trainParam.epochs=1000;
% net=init(net);

DELETE. They are defaults.

% Train the Network
% rng(0)
% [net,tr] = train(net,inputs,targets,inputStates,layerStates);
% tr=tr;

Remove semicolon to see the detailed training record

% Test the Network
% outputs = net(inputs,inputStates,layerStates);
% errors = gsubtract(outputs, targets);
% errors2=cell2mat(errors);
% errors3=(abs(errors2)./y(1:2,22:320))*100; %Change here when you change Time Delay
% performance = perform(net,targets,outputs)

DELETE. Obtain performance from tr.

%Now close the loop

Worry about that later.

Hope this elps.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.