Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I am trying to migrate IRIS Classification sample in the repo here to v1.0.0-preview.
While loading the model for prediction I am getting the below error at the statement
trainedModel = mlContext.Model.Load(stream, out var modelInputSchema);
System.InvalidOperationException
HResult=0x80131509
Message=Error during class instantiation
Source=Microsoft.ML.Core
StackTrace:
at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstanceCore(Object[] ctorArgs)
at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes](IHostEnvironment env, Type signatureType, TRes& result, String name, String options, Object[] extra)
at Microsoft.ML.Runtime.ComponentCatalog.TryCreateInstance[TRes,TSig](IHostEnvironment env, TRes& result, String name, String options, Object[] extra)
at Microsoft.ML.ModelLoadContext.TryLoadModelCore[TRes,TSig](IHostEnvironment env, TRes& result, Object[] extra)
at Microsoft.ML.ModelLoadContext.TryLoadModel[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
at Microsoft.ML.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
at Microsoft.ML.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
at Microsoft.ML.ModelOperationsCatalog.Load(Stream stream, DataViewSchema& inputSchema)
at MulticlassClassification_Iris.Program.TestSomePredictions(MLContext mlContext) in C:\GitRepos\machinelearning-samples-v1.0.0-Preview\samples\csharp\getting-started\MulticlassClassification_Iris\IrisClassification\IrisClassificationConsoleApp\Program.cs:line 99
at MulticlassClassification_Iris.Program.Main(String[] args) in C:\GitRepos\machinelearning-samples-v1.0.0-Preview\samples\csharp\getting-started\MulticlassClassification_Iris\IrisClassification\IrisClassificationConsoleApp\Program.cs:line 36
Inner Exception 1:
TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception 2:
InvalidOperationException: Error during class instantiation
Inner Exception 3:
TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception 4:
InvalidOperationException: Error during class instantiation
Inner Exception 5:
TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception 6:
FormatException: Couldn't load model: 'TransformerChain\Transform_002\Transform_000\Model'
the dataset format is like this
#Label Sepal length Sepal width Petal length Petal width
0 5.4 3.7 1.5 0.2
0 4.8 3.4 1.6 0.2
0 4.8 3.0 1.4 0.1
0 4.3 3.0 1.1 0.1
I have pushed the code to the Github repo here https://github.com/dotnet/machinelearning-samples/tree/migration/1.1.0-preview/samples/csharp/getting-started/MulticlassClassification_Iris
I did not understand the reason for the error. Could anyone help
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
prathyusha12345 commentedon Apr 5, 2019
Before this exception I am getting schema mismatch exception as below
Schema mismatch for label column '': expected Key < UInt32 >, got Single
Parameter name: labelCol
To fix this exception I have added MapValuetoKey() and MapKeyToValue() transformations. Then when I start executing sample I am getting the other exception that it couldn't load model as mentioned earlier.
prathyusha12345 commentedon Apr 5, 2019
adding @CESARDELATORRE for reference. This issue is happening only with SdcaNonCalibrated trainer
[-]Getting an exception while loading the model in MultiClass Classification_IRIS[/-][+][1.0.0-preview] Getting an exception while loading .ZIP model MultiClass-Classification trained with SdcaNonCalibrated[/+][-][1.0.0-preview] Getting an exception while loading .ZIP model MultiClass-Classification trained with SdcaNonCalibrated[/-][+][1.0.0-preview] Bug? - Getting an exception while loading .ZIP model MultiClass-Classification trained with SdcaNonCalibrated[/+]CESARDELATORRE commentedon Apr 5, 2019
Just to mention that right after training the model (multi-class classification) with SdcaNonCalibrated, the model works for making predictions.
However, we save it to a .ZIP file and when we try to load it is when we get the exception.
Also, we have tried with 3 different samples and three different datasets. We get the same behavior.
When using SdcaNonCalibrated it fails in all those samples with different datasets.
If using another algorithm such as OVAAveragedPercentronTrainer, the model loads properly from the .ZIP file and the scenario works good end-to-end.
So looks like a bug related to SdcaNonCalibrated?
prathyusha12345 commentedon Apr 5, 2019
@Ivanidzo4ka Do I need to upgrade to latest version of ML.Net instead of ML.Net 1.0.0-preview to fix this error my sample?
Ivanidzo4ka commentedon Apr 5, 2019
Here is PR towards 1.0 branch. #3220
I hope all you need to do on your side is to update to latest 1.0.0-preview nuget after it would get merge.
@shauheen for clarification.