Marco Armenta
Marco Armenta

Reputation: 33

How to obtain weight matrices during training on Scikit

I am training a MLPClassifier by using Scikit. Lets say I want to train for 5 epochs on MNIST with one hidden layer of 100 neurons.

If I do "mlp = MLPClassifier(...)" and then "mlp.fit(train,test)", then I can obtain the trained weights with "mlp.coefs_".

But what I want is the sequence of weight matrices obtained after each epoch during training. So if I train for 5 epochs I would want a list of size 5 with the history of weight matrices.

Is this possible with scikit? Or should I use Keras?

Upvotes: 1

Views: 609

Answers (1)

jawsem
jawsem

Reputation: 771

One option is to train your model with a fraction of the epochs you wanted to do.

Store the parameters.

Then continue training your model with the warm_start = True parameter. You would do this until you got the overall number of epochs you wanted.

In the context of sci-kit learns implementation the max_iter parameter would be the epochs. This is referenced in this link.
https://stats.stackexchange.com/questions/284491/are-the-epochs-equivalent-to-the-iterations

Upvotes: 1

Related Questions