MATLAB: How to know the number of the hidden nodes in ANN

Deep Learning Toolboxi-h-oneural networkneural networks

Hi All
having an ANN network , in I inputs and O outputs, how do we know the number of hidden nodes? is it related to the number of hidden layers ?
when designing an I H O topology , when you set the Hmax and Hmin and dH , you can change the number of trials by changing any of the Hmin , Hmax or even dH
what is the main rule ? and advised relation between dH and Hmin ? should they be specific numbers ?
In NO book it is discussed .

Best Answer

[I N ] = size(input) % size("I"nput)
[O N ] = size(target) % size("O"utput)
Ntrn = N - 2*round(0.15*N) % Default no. of training examples ~ 0.7*N
Ntrneq = Ntrn*O % No. of training equations
Nw = (I+1)*H +(H+1)*O % No. of unknown weights for H = number of hidden nodes
Overfitting ( Nw > Ntrneq ) allows decreased performance on nontraining (e.g., val, test and unseen) data
Since H > ( Ntrneq -O )/(I+O+1) for overfitting, one training strategy is H <= Hub or preferably, H << Hub where
Hub = -1 + ceil( (Ntrneq - O) / (I+O+1) ) % integer H
My training strategy:
Minimize the number of hidden nodes subject to the constraint that the mean-square-error is less than 1 percent of the mean target variance
net.trainPerform.goal = 0.01*mean(var(target',1)))
Very often this is accomplished by trial and error subject to
0 <= Hmin <= H <= Hmax <= Hub
However, sometimes it is necessary to exceed Hub. The mitigation for this is
Validation Stopping and/or regularization (e.g., msereg or TRAINBR}
Hope this helps.
Thank you for formally accepting my answer
Greg