How to initialize weight and biases for single hidden layer ?

2 views (last 30 days)
Hello Everyone ! Please i need your help !
In order to create artificial neural networks for solar radiation prediction, I need to define architecture of my NNs, especially the number of hidden neurons because i use one hidden layer. So, i would like to use the following approach: Fix the initial conditions (weights and biases) and vary the number of hidden neurons from 1 to 20, till i find architecture that gives best performance.
My questions is : How do i use 'net = init(net)' in this code ?
x = simplefitInputs;
t = simplefitTargets;
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. NFTOOL falls back to this in low memory situations.
trainFcn = 'trainlm'; % Levenberg-Marquardt
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
% View the Network
view(net)
If there are other approaches, do not hesitate to mention them.
Thank you.

Answers (0)

Community Treasure Hunt

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

Start Hunting!