Question How do you calculate the number of hidden layers and neurons for a neural network


New member
Feb 14, 2020
Programming Experience
I followed a tutorial on how to make a neural network to learn the OR operation for three inputs and now I want to change it so that it can take 24 inputs and return 2 outputs. Do you know how what number of hidden layers and number of neurons in each hidden layer would produce the best results, or any changes that I should make to the code to account for the changes? Thanks.

Link to the project:


Well-known member
Apr 6, 2019
Virginia Beach, VA
Programming Experience
I just know general principles about how neural networks work. I am not involved in day to day design, training, and use of them. My understanding, though, is that it really depends on the level of weighting you want and how many layers you want. Since a hidden layer is defined to be zero or more layers, then you could potentially have zero nodes for the hidden layer. Depending on what you are trying to achieve, this may work if you set up the weights for the 24 inputs going to the 2 outputs just right. On the other hand if you need something deeper that can be more tolerant of varying inputs, then obviously you'll need more than zero nodes in the hidden layer, and possibly more than one layer within the hidden layer. It'll really depend on your training data and what you are trying to achieve.
Top Bottom