Restoring a cancelled ML.NET trained network #AI #MachineLearning #ML.NET
If you’re using the ML.NET VS Add-in to train your models, you may find it really frustrating if the training suddenly cancels itself, or you accidentally cancel it, and if you’re doing an 8 hour train, then this can drive you nuts.
Thankfully, I found the temporary files, that it generates, and you can still use in your code, although it generates about 10 different models per algorithm, so you’ll need to experiment to find the one that works best (typically it’ll be the 9th or 10th)
So, where are the files?
<user>\AppData\Local\Temp\Microsoft.ML.AutoML
Phew!
And how to load them in?, here’s some sample code;
private static ModelOutput Predict(ModelInput input)
{if (predictionEngine == null)
{
// Create new MLContext
MLContext mlContext = new MLContext();ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema);
predictionEngine = mlContext.Model.CreatePredictionEngine<ModelInput, ModelOutput>(mlModel);
}// Use model to make prediction on input data
var result = predictionEngine.Predict(input);
return result;
}
Where you statically define the following variables;
private static PredictionEngine<ModelInput, ModelOutput> predictionEngine = null;
private static string modelPath = @””;
modelpath being the ZIP file of the model.