首页 > 解决方案 > 如何重新训练/更新 keras 模型?

问题描述

如何在不从头开始重新训练的情况下更新/附加新数据到我的模型?我的数据集是图像,输出是预测情绪。

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

Model.fit 似乎没有附加我的新数据,而是覆盖了模型。我的输出只有一个(我更新的最后一个)。

加载经过训练的 Keras 模型并继续训练

我已经搜索过这个,但效果不佳。

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

标签: pythontensorflowkeras

解决方案


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).


推荐阅读