[scikit-learn] MLP Classifier error in 0.18 version

Andreas Mueller t3kcit at gmail.com
Fri Oct 7 11:47:55 EDT 2016


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 list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161007/073321f4/attachment.html>


More information about the scikit-learn mailing list