简体   繁体   English

如何重新训练/更新 keras 模型?

[英]How to retrain/update keras model?

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. Model.fit 似乎没有附加我的新数据,而是覆盖了模型。 My output is only one (the last one that I updated).我的输出只有一个(我更新的最后一个)。

Loading a trained Keras model and continue training 加载经过训练的 Keras 模型并继续训练

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.编辑 1:当我们丢失以前训练的数据时我们能做什么。 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.简而言之,我们在训练完成后立即丢失了训练数据,并且无法再次取回数据,我们必须保留的是从中完成的学习,并在收到新数据时重新训练模型。

It is really easy.这真的很容易。 For instance model.save() in Keras can save the model weights, which is what you actually need to keep.例如model.save()可以保存模型权重,这是您实际需要保留的。

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).每个新纪元都会通过所有图像(新的和旧的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM