I have already trained a neural network on my data. In the future, I will receive some more data. How can I incorporate this data into my model without rebuilding it from scratch?
In keras, you can save your model using
model.save and then load that model using
model.load. If you call
.fit again on the model that you’ve loaded, it will continue training from the save point and will not restart from scratch. Each time you call
.fit, keras will continue training on the model.
.fit does not reset model weights.
I would like to point out one issue that might arise from training your model this way though, and that issue is catastrophic forgetting. If you feed your model examples that differ significantly from previous training examples, it might be prone to catastrophic forgetting. This is basically when the neural network learns your new examples well and forgets all the previous examples because you are no longer feeding those examples to it. It arises because as optimizers get more efficient, the neural network will be get more efficient at fitting new data quickly – and the best way to fit the new data quickly might be to forget old data. If your future data is very similar to your current data, then this won’t be a problem. But imagine you trained a named entity recognition system to recognize organizations. If in the future you feed it a bunch of data that teach it how to recognize people names, it might catastrophically forget how to recognize organizations.