5

How to update/append new data to my model without starting to retrain from scratch? My dataset are images and the output is to predict emotion.

model.fit(x=train_image, y=train_label, epochs=1, batch_size=1)

Model.fit seems not appending my new data but overwriting the model. My output is only one (the last one that I updated).

Loading a trained Keras model and continue training

I've already search for this but doesn't work as well.

Edit 1: What can we do when we lose our previously trained data. In simple words we lose our training data just after the training is completed and we can not get the data back again, just the thing we have to retain is the learning done from it and also retrain the model when we receive new data.

Mousam Singh
  • 675
  • 2
  • 9
  • 29
lambda
  • 990
  • 1
  • 10
  • 29
  • What exactly is not working? Do you get any error messages? Do you also save the state of your optimizer somewhere? – Hagbard Jan 25 '19 at 10:25
  • @Hagbard Yes, I do save it and there's no error with it. The problem is it keeps on overwriting my model everytime I retrain/update it using model.fit. – lambda Jan 27 '19 at 23:56

1 Answers1

3

It is really easy. For instance model.save() in Keras can save the model weights, which is what you actually need to keep.

After that you can add new images to your training set, but just use the weights you saved.

Every new epoch will pass trough all the images (new and old).

prosti
  • 42,291
  • 14
  • 186
  • 151