According to the documentation, it says the 'activation' argument specifies:

"Activation function for the hidden layer"

Does that mean that you cannot use a different activation function in different layers?


1 Answer 1


One can see from the code (look at uses of self.activation) that the same function is used for all the hidden layers.

You might want to consider the comments to this question for alternative approaches, generally being a move away from sklearn and towards a deep learning framework.

  • 1
    $\begingroup$ Hi, Thank you. But the code you have linked is not available anymore $\endgroup$ Commented May 28, 2021 at 17:33
  • $\begingroup$ Hi @DiliniPeiris, thanks for letting me know. I've updated the link in response to the maintainers of sklearn changing the module name. $\endgroup$
    – mapto
    Commented May 29, 2021 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.