dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.29k stars 5.92k forks source link

FormatException: Couldn't load model: 'TransformerChain\Transform_001\Model' #12174

Closed mhectorgato closed 5 years ago

mhectorgato commented 5 years ago

Using v1 RC, I built my model as such: var trainingPipeline = modelConfig.pipeline .Append(modelConfig.mlContext.MulticlassClassification.Trainers .SdcaNonCalibrated("Label", "Features")) .Append(modelConfig.mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

Then later on when trying to load the mode zip, I get the following error: FormatException: Couldn't load model: 'TransformerChain\Transform_001\Model'

Code to load the model (exception is thrown in the .Load call) ITransformer loadedModel; using (var stream = new FileStream(modelPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { loadedModel = _mlContext.Model.Load(stream, out var modelInputSchema); }

The Model.Load code worked correctly with a model trained like these: var trainingPipeline = modelConfig.pipeline .Append(modelConfig.mlContext.MulticlassClassification.Trainers .LbfgsMaximumEntropy("Label", "Features")) .Append(modelConfig.mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel")); and var trainingPipeline = modelConfig.pipeline .Append(modelConfig.mlContext.MulticlassClassification.Trainers .SdcaMaximumEntropy("Label", "Features")) .Append(modelConfig.mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

mhectorgato commented 5 years ago

Works correctly in release version 1.