Dense Layer and node size

How to calculate the number of layers and node size

Hello @umairmughal70,

There is no formula that we can use to calculate how many layers and neurons are needed to build a sufficiently good NN architecture that can finally be tuned to perform well. Instead, we try different architectures and tune other hyperparameters to experiment which configuration gives the best score on our cross validation dataset.

As you try experimenting more, you may come up with a set of empirical rules yourself on what the network should look like for your problem domain. For example, in some problems, we usually allocate more neurons than the number of features to give the NN enough freedom but at the same time apply regularization to suppress overfitting. As for how many more neurons will give enough freedom, it’s again by experiment and no formula can get us to that number.

Cross validation dataset, overfitting and regularization are topics that are covered in the first 2 courses of this MLS.

Our labs are good starting point for you to experiment. Reading online tutorials is another way for you to know what architecture was chosen on a particular theme or dataset in that tutorial.

Raymond

Hi @rmwkwok , Thanks for clearing