Initialize weights in sklearn.neural_network

Viewed 2504

I want to initialize weights in a MLPclassifier, but when i use sample_weight in .fit() method, it says that TypeError: fit() got an unexpected keyword argument 'sample_weight'

import sklearn.neural_network as SKNN

mlp_classifier = SKNN.MLPClassifier((10,), learning_rate="invscaling",solver="lbfgs")

fit_model = mlp_classifier.fit(train_data,train_target,  sample_weight = weight)

i also read What does `sample_weight` do to the way a `DecisionTreeClassifier` works in sklearn?, it said that you should use sample_weight in the .fit() method.

is there any way to use sample_weight for MLPclassifier like the one used in Decisiontreeclassifier ?

3 Answers

There are no sample weights in sklearn NN yet. But you can as the start:

  1. find it in Keras: https://keras.io/models/sequential/
  2. write the NN in numpy and implement sample_weight by yourself
Related