Lets say I\'m creating a neural net using the following code:
from sklearn.neural_network import MLPRegressor
model = MLPRegressor(
hidden_layer_sizes=(100,),
From the docs:
hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)
The ith element represents the number of neurons in the ith hidden layer.
It is length = n_layers - 2
, because the number of your hidden layers is the total number of layers n_layers
minus 1 for your input layer, minus 1 for your output layer.
In your (default) case of (100,)
, it means one hidden layer of 100 units (neurons).
For 3 hidden layers of, say, 100, 50, and 25 units respectively, it would be
hidden_layer_sizes = (100, 50, 25)
See the example in the docs (it is for MLPClassifier
, but the logic is identical).