Choice of neurons in hidden layer


How to choose how many hidden layers and how many neurons per hidden layer? For example, in the case of ECG diagram, why do you choose to group every 20 lines into one neuron in the hidden layer? does it represent the average frequency of a peak that would occur? In coffee example, it is visible there are 3 borders, but what about the other applications?


Hi @Yixuan_Li-Verdoold

There is a topic about this on this Thread

Also if you still confused about thing, please feel free to ask it


In addition to the reference provided by @AbdElRhaman_Fakhry , I would add this:

The number of nodes, and even the hidden layers, are determined by the architect of the NN, like you for instance.

While defining the architecture of your NN you have several options:

  1. You can get started with a known model which has been created by some researchers, and this model proposes already a certain amount of layers, and nodes inside of each layer.
  2. You can start from scratch.
    2.1 Assuming you are a very experienced ML designer, may be you’ll get started with a configuration that, from experience, it is the best layout for the task at hand.
    2.2 Assuming you are a novice, you may start with your best guess. For instance, 2 hidden layers, each with 4 nodes.

In any case, you’ll design your NN, train it, and watch the results. If the results are not meeting your objectives, then you start ‘fine-tuning’ your architecture (although fine-tuning the data may be more important, but that’s another topic). At the end you will hopefully reach a design (number of layers, number of units inside each layer, etc) that meets your objective.

I hope this sheds more light on your question.



in my model, i get the best results when I set my NN model architecture to be 12 hidden layers with 120 neurons for each
is it norma?

Actually anything that works is ‘normal’. It will depend very much on your specific case.

1 Like