[scikit-learn] MLP Classifier error in 0.18 version

Aakash Agarwal aakash at klugtek.co.in
Fri Oct 7 14:52:31 EDT 2016


Hi Andy,

Thanks for the quick reply. Basically i am randomly choosing 90% training
data from the data set and fitting the classifier again and again. First
few transactions are working fine but after that it is failing in between.
So like you mentioned, standalone fitting is happening.

But as you said, warm_start seems to be the issue. Since i was choosing
data randomly, total number of labels in a single batch was not constant
over multiple iterations and it could not detect new labels from the
previous model and thus failed.

Thanks a lot for the valuable inputs.
Aakash

On Fri, Oct 7, 2016 at 9:17 PM, Andreas Mueller <t3kcit at gmail.com> wrote:

> Hi.
> Can you provide a self-contained example to reproduce on the issue-tracker?
> Maybe you used warm_start=True but changed something about the dataset,
> like going from 125 classes to 128?
>
> This works:
>
> from sklearn.neural_network import MLPClassifier
> gen_class = MLPClassifier(hidden_layer_sizes=(200,),max_iter=3000,
> learning_rate='adaptive',alpha=0.025,warm_start=True)
> X_train = np.random.uniform(size=(398, 50))
> y_train = np.random.uniform(size=398) > .5
> gen_class.fit(X_train, y_train)
>
> best,
> Andy
>
>
> On 10/07/2016 09:51 AM, Aakash Agarwal wrote:
>
> Hi Guys,
>
> I am playing around MLP classifier lately. So i have about 450 inputs to
> classify. Each input is a vector of array size 50. I am trying to fit the
> model with 90% as train data.
>
> Size of training data: (398, 50)
> Size of testing data: (45, 50)
>
> MLP instantiation:
> gen_class = MLPClassifier(hidden_layer_sizes=(200,),max_iter=3000,
> learning_rate='adaptive',alpha=0.025,warm_start=True)
>
> Batch size is auto so it is taking 200 as batch_size. But when i am
> fitting the classifier model, i am getting following error:
>
> Traceback (most recent call last):
>   File "intent_detection_classifier_selection.py", line 452, in <module>
>     sk_class.gen_class_fitting(gen_class,corp_lsi_train,train_label)
>   File "intent_detection_classifier_selection.py", line 77, in
> gen_class_fitting
>     gen_class.fit(data,label)
>   File "/usr/local/lib/python2.7/dist-packages/sklearn/neural_
> network/multilayer_perceptron.py", line 612, in fit
>     return self._fit(X, y, incremental=False)
>   File "/usr/local/lib/python2.7/dist-packages/sklearn/neural_
> network/multilayer_perceptron.py", line 372, in _fit
>     intercept_grads, layer_units, incremental)
>   File "/usr/local/lib/python2.7/dist-packages/sklearn/neural_
> network/multilayer_perceptron.py", line 509, in _fit_stochastic
>     coef_grads, intercept_grads)
>   File "/usr/local/lib/python2.7/dist-packages/sklearn/neural_
> network/multilayer_perceptron.py", line 225, in _backprop
>     loss = LOSS_FUNCTIONS[self.loss](y, activations[-1])
>   File "/usr/local/lib/python2.7/dist-packages/sklearn/neural_network/_base.py",
> line 222, in log_loss
>     return -np.sum(y_true * np.log(y_prob)) / y_prob.shape[0]
> ValueError: operands could not be broadcast together with shapes (200,128)
> (200,125)
>
> Thanks,
> Aakash
>
>
> _______________________________________________
> scikit-learn mailing listscikit-learn at python.orghttps://mail.python.org/mailman/listinfo/scikit-learn
>
>
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>


-- 
Thanks,
Aakash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161008/93f9a6e0/attachment.html>


More information about the scikit-learn mailing list