Yes,you are right @ Raghav R V, thx! However, i found the key param is ‘hidden_layer_sizes=[2]’, I wonder if I misunderstand the meaning of parameter of hidden_layer_sizes?
Is it related to the topic : http://stackoverflow.com/questions/36819287/mlp-classifier-of-scikit-neuralnetwork-not-working-for-xor 发件人: scikit-learn [mailto:[email protected]] 代表 Raghav R V 发送时间: 2016年11月23日 19:04 收件人: Scikit-learn user and developer mailing list 主题: Re: [scikit-learn] question about using sklearn.neural_network.MLPClassifier? Hi, If you keep everything at their default values, it seems to work - ```py from sklearn.neural_network import MLPClassifier X = [[0, 0], [0, 1], [1, 0], [1, 1]] y = [0, 1, 1, 0] clf = MLPClassifier(max_iter=1000) clf.fit(X, y) res = clf.predict([[0, 0], [0, 1], [1, 0], [1, 1]]) print(res) ``` On Wed, Nov 23, 2016 at 10:27 AM, <[email protected]<mailto:[email protected]>> wrote: Hi everyone I try to use sklearn.neural_network.MLPClassifier to test the XOR operation, but I found the result is not satisfied. The following is code, can you tell me if I use the lib incorrectly? from sklearn.neural_network import MLPClassifier X = [[0, 0], [0, 1], [1, 0], [1, 1]] y = [0, 1, 1, 0] clf = MLPClassifier(solver='adam', activation='logistic', alpha=1e-3, hidden_layer_sizes=(2,), max_iter=1000) clf.fit(X, y) res = clf.predict([[0, 0], [0, 1], [1, 0], [1, 1]]) print(res) #result is [0 0 0 0], score is 0.5 _______________________________________________ scikit-learn mailing list [email protected]<mailto:[email protected]> https://mail.python.org/mailman/listinfo/scikit-learn -- Raghav RV https://github.com/raghavrv
_______________________________________________ scikit-learn mailing list [email protected] https://mail.python.org/mailman/listinfo/scikit-learn
