modAL icon indicating copy to clipboard operation
modAL copied to clipboard

does the model re-created during learner.teach period?

Open Luckyxuli opened this issue 6 years ago • 2 comments

i used model.summary() in create_keras_model() function, and i set n_queries=10, i saw the model summary info at each iteration, why this happend?

Luckyxuli avatar Oct 28 '19 07:10 Luckyxuli

I have the same question, I highly appreciate any help to resolve this problem. It seems like the model is re-created at each teach step while what we want is to continue the training with the queried examples.

siahdohoni avatar Oct 29 '19 17:10 siahdohoni

Hi!

This is how the scikit-learn wrapper is implemented in Keras. If you check out how its .fit() method is implemented, you can see that it calls the builder function every time it is called.

In modAL, training in the ActiveLearnar.teach() method uses all the samples, not just the new ones. However, with this, training has to be restarted from scratch every time.

I was not aware until now that this is how the wrapper works. I'll create a wrapper class for the KerasClassifier which won't reconstruct the model by overwriting the .fit() method, but this is not the best solution. The best would be to submit a PR to Keras which makes keeping the model optional, but I am not sure it will be accepted.

cosmic-cortex avatar Oct 29 '19 17:10 cosmic-cortex