Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sklearn MLPClassifier - zero hidden layers (i.e. logistic regression)

We know that a feed forward neural network with 0 hidden layers (i.e. just an input layer and an output layer) with a sigmoid activation function at the end should be equivalent to logistic regression.

I wish to prove this to be true, but I need to fit 0 hidden layers using the sklearn MLPClassifier module specifically.

My attempt:

my_nn = MLPClassifier(hidden_layer_sizes=(0), alpha = 0, 
                        max_iter=10000)

but this results in an error message:

hidden_layer_sizes must be > 0, got [0, 0].

Is there any way to achieve this using this specific module?

like image 762
aranglol Avatar asked Oct 30 '25 11:10

aranglol


1 Answers

You can try like

my_nn = MLPClassifier(hidden_layer_sizes=(), alpha = 0, max_iter=10000)

like image 196
drorhun Avatar answered Nov 01 '25 03:11

drorhun



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!