5

I am trying to code a multilayer perceptron in scikit learn 0.18dev using MLPClassifier. I have used the solver lbgfs, however it gives me the warning : ConvergenceWarning: Stochastic Optimizer: Maximum iterations reached and the optimization hasn't converged yet. % (), ConvergenceWarning)

How can I fix this?

endive1783
  • 827
  • 1
  • 8
  • 18
  • 1
    increase the maximum interations? – maxymoo Sep 20 '16 at 01:35
  • i tried that, it doesn't help. I took the max iterations upto 200000, but still getting same warning. –  Sep 20 '16 at 04:16
  • what's the output like if you run it with `MLPClassifier(verbose=True)`? – maxymoo Sep 20 '16 at 04:42
  • Weird: if you use lbfgs you should not get a warning referring to "Stochastic Optimizer". Can you check that you still get this error on the current version of master (with `solver='lbfgs'`) and report an issue if with a minimalistic reproduction code snippet if you still experience the issue. – ogrisel Sep 21 '16 at 08:20
  • Actually please update your question to include a minimalistic reproduction code snippet here on stackoverlow: http://scikit-learn.org/dev/faq.html#what-s-the-best-way-to-get-help-on-scikit-learn-usage – ogrisel Sep 21 '16 at 08:22
  • 4
    I had the same error, and increasing the number of iterations to a substantial number solved this error in my case – Hamman Samuel Jan 18 '17 at 15:31

1 Answers1

3

How about setting hidden_layer_sizes and max_iter parameters?

mlp = MLPClassifier(solver='lbfgs', hidden_layer_sizes=[100], max_iter=2000, activation='logistic')
Sang-Kil Park
  • 101
  • 2
  • 16