Reputation: 191
I have trained a model using sklearn.neural_network.MLPClassifier
and I want to know how many layers are in my clssifier. The result shows :
>>from sklearn.neural_network import MLPClassifier
>>clf = MLPClassifier()
>>clf = clf.fit(train_matrix,train_label)
>>clf.n_layers_
>>3
The document shows attribute n_layers_ means :
Number of layers
Dose it mean there is a hidden layer or there are three hidden layers?
Upvotes: 2
Views: 2149
Reputation: 36599
n_layers_
denotes all the layers in the neural network which include
len(hidden_layer_sizes)
So if you initialized the classifier as
clf = MLPClassifier()
The default hidden_layer_sizes
param = (100,)
, so number of hidden layers = 1.
So total layers = 1+1+1 = 3 as you are getting.
If instead you initialized it as:
clf = MLPClassifier(hidden_layer_sizes=(100,100,))
Now the number of hidden layers = 2, so total layers = 4
Upvotes: 7