How can I use Neural Networks to create several networks instead of creating one by one manually?

5 views (last 30 days)
Hey,
I would like to create several neural networks models and estimations using for each one of them 2 variables as inputs and 1 variable as output. For a single stock I would use the NNtool to first construct the model and then do the estimation. What I would like to know is how could I do this for all the stocks (30 stocks and for each one of them I would like to create a nn estimation) in an automatic way without having to run the wizard for each one of them.
Thanks you for your support,
Best regards,
Sarah

Accepted Answer

Greg Heath
Greg Heath on 28 Apr 2014
You can do it with nested for loops. Indexed nets should be stored in cells. However, it is not clear what the difference in inputs is for the 30 stocks. Also, what are the outputs? I assume this is regression and not classification. Therefore you should use the FITNET version of feedforwardnet (NEWFIT version of newff if you are using the obsolete version).
A single hidden layer is sufficient. Accept all defaults except the number of hidden nodes, H=10; Try to use the smallest value of H that yields acceptable results.
Also, you have to take into account that some designs will be bad because of an unfortunate assignment of random initial weights. Therefore, for each case, multiple random initial weight designs will have to be made to obtain an acceptable one.
I typically look at Ntrials = 10 random initialization designs for each of ~10 candidate values for H. Search using
greg fitnet Ntrials
Hope this helps.
Thank you for formally accepting my answer
Greg
  2 Comments
Sarah
Sarah on 28 Apr 2014
Hey!
Thank you for your support but since I am new to matlab I still do not totally understood how could I implement the code.
I have attached a pdf of an example of the data I have. The objective is use X11 and X21 to regress to Y1 (X12 X22 to Y2 and so on), using the first 80% of the data to build and train each model and the last 20% of the data to estimate and evaluate the results and errors. Therefore what I want to get is end is the 30 estimations for the 30 stocks.
Could you exemplify the code you would use to do this?
Thanks a lot for your help!

Sign in to comment.

More Answers (1)

Apdullah YAYIK
Apdullah YAYIK on 27 Apr 2014
Of course you can create several neural networks and control their variables (transfer functions, hidden layers, neuron numbers of training algorithms)for your estimation or classification problems. For example ---First ANN--- nn=10;mm=10;pp=10; %%Neuron Numbers net1=newfit(minmax(target{1,1}),[nn,mm,pp,1],{'radbas','purelin','radbas','purelin','radbas'},'trainbr'); net1.trainparam.min_grad=0; net1.trainparam.mu_max=1.e+10; net1.trainParam.epochs=20; net1=train(net1,target{1,1},acik_bin_reshaped{1,1}); ---Second ANN--- net2=newfit(minmax(target{1,2}),[nn,mm,pp,1],{'radbas','purelin','radbas','purelin','radbas'},'traingda'); net2.trainparam.min_grad=0; net2.trainparam.mu_max=1.e+10; net2.trainParam.epochs=20; net2=train(net2,target{1,2},acik_bin_reshaped{1,2}); ---Third ANN--- %%%%%%%%%%%%%%%%%%%%%3.Boyut NN%%%%%%%%%%%%%%%%%%%%% net3=newfit(minmax(target{1,3}),[nn,mm,pp,1],{'radbas','purelin','radbas','purelin','radbas'},'traingda'); net3.trainparam.min_grad=0; net3.trainparam.mu_max=1.e+10; net3.trainParam.epochs=20; net3=train(net3,target{1,3},acik_bin_reshaped{1,3});
Then, you can simulate each of them independently.
output1=sim(net1,target{1,1}); output2=sim(net2,target{1,2}); output3=sim(net3,target{1,3});
  1 Comment
Sarah
Sarah on 27 Apr 2014
Hey Apdullah,
Thank you for your quick response. However I did not totally understand how could I do it.
What does nn mm and pp mean? what is it like the target{1,1}, is it an array with the target values? What does the acik_bin_reshaped{1,2} mean? Can you better explain to me these variables?
Lets say that we have 30 stocks and we want to do a model for each one of them with two input variables and one output variable. Do I have do do write that code 30 times and refer to the different inputs and outputs or can I do it with a for or other cycle?
Thank you again for your time!

Sign in to comment.

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!