Python scikit learn MLPClassifier "hidden_layer_sizes"

Chubaka picture Chubaka · Feb 12, 2016 · Viewed 62.8k times · Source

I am lost in the scikit learn 0.18 user manual (http://scikit-learn.org/dev/modules/generated/sklearn.neural_network.MLPClassifier.html#sklearn.neural_network.MLPClassifier):

   hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)
   The ith element represents the number of neurons in the ith hidden layer.

If I am looking for only 1 hidden layer and 7 hidden units in my model, should I put like this? Thanks!

    hidden_layer_sizes=(7, 1)

Answer

Farseer picture Farseer · Feb 12, 2016

hidden_layer_sizes=(7,) if you want only 1 hidden layer with 7 hidden units.

length = n_layers - 2 is because you have 1 input layer and 1 output layer.