Skip to content

[1.0.0-preview] Bug? - Getting an exception while loading .ZIP model MultiClass-Classification trained with SdcaNonCalibrated #3209

Closed

Description

@prathyusha12345

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

Activity

  1. prathyusha12345 commented on Apr 5, 2019

    @prathyusha12345
    Author

    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.

  2. prathyusha12345 commented on Apr 5, 2019

    @prathyusha12345
    Author

    adding @CESARDELATORRE for reference. This issue is happening only with SdcaNonCalibrated trainer

  3. changed the title [-]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[/+] on Apr 5, 2019
  4. changed the title [-][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[/+] on Apr 5, 2019
  5. CESARDELATORRE commented on Apr 5, 2019

    @CESARDELATORRE
    Contributor

    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?

  6. self-assigned this
    on Apr 5, 2019
  7. prathyusha12345 commented on Apr 5, 2019

    @prathyusha12345
    Author

    @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?

  8. Ivanidzo4ka commented on Apr 5, 2019

    @Ivanidzo4ka
    Contributor

    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.

  9. ghost locked as resolved and limited conversation to collaborators on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions