Home > Uncategorized > Restoring a cancelled ML.NET trained network #AI #MachineLearning #ML.NET

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?



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.



Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: