ML.Net重新训练现有模型,而不是训练新模型 [英] ML.Net retrain existing model rather than training new model

查看:107
本文介绍了ML.Net重新训练现有模型,而不是训练新模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在训练ML.Net机器学习模型。我可以训练它并从中进行预测,然后从磁盘保存/加载它。但是我需要能够将其从磁盘上加载,然后对其进行重新培训,或者添加新的信息以随着时间的推移对其进行改进。

I am training a ML.Net machine learning model. I can train it and predict from it, and save/load it from the disk. But I need to be able to load it off the disk, then retrain it, or add to it with new information to improve it over time.

有人知道吗有可能吗我没有在MS文档中找到如何做的任何事情,但这对于ML来说是很标准的事情,因此如果无法实现,我会感到惊讶。

Does anyone know if this is possible? I have not found anything in the MS docs of how to do it, but it's a pretty standard thing for ML, so I'd be surprised if it's not possible.

谢谢

推荐答案

此功能存在于ML.NET中,但现有的 LearningPipeline无法实现 API。这将在新的ML.NET API中公开,并且可以找到启用此方案的示例此处。相关代码为:

This functionality exists in ML.NET but it is not possible with the existing LearningPipeline APIs. This will be exposed in the new ML.NET APIs and a sample enabling this scenario can be found here. The relevant code is:

// Train the first predictor.
var trainer = new LinearClassificationTrainer(env, new LinearClassificationTrainer.Arguments
{
    NumThreads = 1
}, "Features", "Label");
var firstModel = trainer.Fit(trainData);

// Train the second predictor on the same data.
var secondTrainer = new AveragedPerceptronTrainer(env, new AveragedPerceptronTrainer.Arguments());

var trainRoles = new RoleMappedData(trainData, label: "Label", feature: "Features");
var finalModel = secondTrainer.Train(new TrainContext(trainRoles, initialPredictor: firstModel.Model));

这些API仍在不断发展,但这也许有所帮助。这还不是官方ML.NET版本的一部分,因此您需要从此处或构建存储库

These APIs are still in flux, but perhaps this helps. This is not yet part of an official ML.NET release so you would need to get a NuGet from here or build the repo.

注意:我是ML.NET团队的成员。

Note: I am on the ML.NET team.

这篇关于ML.Net重新训练现有模型,而不是训练新模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆