Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scikit learn multilayer neural network

As per the documentation provided by Scikit learn

hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)

I have little doubt.

In my code what I have configured is

MLPClassifier(algorithm='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)

so what does 5 and 2 indicates?

What I understand is, 5 is the numbers of hidden layers, but then what is 2?

Ref - http://scikit-learn.org/dev/modules/generated/sklearn.neural_network.MLPClassifier.html#

like image 383
user123 Avatar asked Dec 03 '25 13:12

user123


1 Answers

From the link you provided, in parameter table, hidden_layer_sizes row:

The ith element represents the number of neurons in the ith hidden layer

Which means that you will have len(hidden_layer_sizes) hidden layers, and, each hidden layer i will have hidden_layer_sizes[i] neurons.

In your case, (5, 2) means:

  • 1rst hidden layer has 5 neurons
  • 2nd hidden layer has 2 neurons

So the number of hidden layers is implicitely set

like image 165
pltrdy Avatar answered Dec 05 '25 16:12

pltrdy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!