Skip to content

Model Backwards Compatability #1150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HowardvanRooijen opened this issue Oct 4, 2018 · 2 comments · Fixed by #1570
Closed

Model Backwards Compatability #1150

HowardvanRooijen opened this issue Oct 4, 2018 · 2 comments · Fixed by #1570
Assignees
Labels
bug Something isn't working
Milestone

Comments

@HowardvanRooijen
Copy link

HowardvanRooijen commented Oct 4, 2018

Hi

Following up from issue #569 - when using the latest nightly builds 0.7.0-preview-27004-1 models trained using the previous ML.NET release (0.5) fail to load, with the following exception:

   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstanceCore(Object[] ctorArgs)
   at Microsoft.ML.Runtime.ComponentCatalog.LoadableClassInfo.CreateInstance(IHostEnvironment env, Object args, Object[] extra)
   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.Runtime.Model.ModelLoadContext.TryLoadModelCore[TRes,TSig](IHostEnvironment env, TRes& result, Object[] extra)
   at Microsoft.ML.Runtime.Model.ModelLoadContext.TryLoadModel[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.Runtime.Model.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, Entry ent, String dir, Object[] extra)
   at Microsoft.ML.Runtime.Model.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment env, TRes& result, RepositoryReader rep, String dir, Object[] extra)
   at Microsoft.ML.Runtime.Model.ModelLoadContext.LoadModelOrNull[TRes,TSig](IHostEnvironment env, TRes& result, String name, Object[] extra)
   at Microsoft.ML.Runtime.Model.ModelLoadContext.LoadModel[TRes,TSig](IHostEnvironment env, TRes& result, String name, Object[] extra)
   at Microsoft.ML.Runtime.Data.CompositeDataLoader.LoadSelectedTransforms(ModelLoadContext ctx, IDataView srcView, IHostEnvironment env, Func`2 isTransformTagAccepted)
   at Microsoft.ML.Runtime.Model.ModelFileUtils.LoadTransforms(IHostEnvironment env, IDataView data, RepositoryReader rep)
   at Microsoft.ML.Runtime.Model.ModelFileUtils.LoadTransforms(IHostEnvironment env, IDataView data, Stream modelStream)
   at Microsoft.ML.Runtime.Api.ComponentCreation.LoadTransforms(IHostEnvironment env, Stream modelStream, IDataView data)
   at Microsoft.ML.Runtime.Api.DataViewConstructionUtils.LoadPipeWithPredictor(IHostEnvironment env, Stream modelStream, IDataView view)
   at Microsoft.ML.Runtime.Api.BatchPredictionEngine`2..ctor(IHostEnvironment env, Stream modelStream, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition)
   at Microsoft.ML.Runtime.Api.ComponentCreation.CreateBatchPredictionEngine[TSrc,TDst](IHostEnvironment env, Stream modelStream, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition)
   at Microsoft.ML.Legacy.PredictionModel.ReadAsync[TInput,TOutput](Stream stream)
   at Demo.Program.<Main>d__0.MoveNext() in C:\_Projects\OSS\MLNETPreviousModelLoadingError\Demo\Program.cs:line 25

I've attached a small demo that reproduces the above. The zip also contains a model trained on ML.NET 0.5 using the following code:

namespace Endjin.Expenses.Demo
{
    #region Using Directives

    using System.Collections.Generic;

    using Endjin.FreeAgent.Expenses.MachineLearning.Domain;

    using Microsoft.ML.Legacy;
    using Microsoft.ML.Legacy.Data;
    using Microsoft.ML.Legacy.Trainers;
    using Microsoft.ML.Legacy.Transforms;

    #endregion 

    public class ExpenseModelTrainer
    {
        public PredictionModel<TransactionModel, Prediction> Train(IEnumerable<TransactionModel> input)
        {
            var pipeline = new LearningPipeline
            {
                CollectionDataSource.Create(input),
                new TextFeaturizer("Features", nameof(TransactionModel.Description), nameof(TransactionModel.Reference), nameof(TransactionModel.Amount)),
                new Dictionarizer(nameof(TransactionModel.Label)),
                new StochasticDualCoordinateAscentClassifier(),
                new PredictedLabelColumnOriginalValueConverter { PredictedLabelColumn = nameof(Prediction.PredictedLabel) }
            };

            return pipeline.Train<TransactionModel, Prediction>();
        }
    }
}

(The "legacy" namespaces changed in the latest version, but if you change them back to the 0.5 version namespaces - nothing else changed)

MLNETPreviousModelLoadingError.zip

Many thanks,

Howard

@shauheen shauheen added the bug Something isn't working label Oct 5, 2018
@shauheen shauheen added this to the 1018 milestone Oct 5, 2018
@shauheen
Copy link
Contributor

shauheen commented Oct 5, 2018

Thanks @HowardvanRooijen for filing the issue. We are going to investigate the issue for 0.7.

@ganik ganik self-assigned this Oct 8, 2018
@ganik
Copy link
Member

ganik commented Oct 8, 2018

I ll take a look, thx

@shauheen shauheen modified the milestones: 1018, 1118 Nov 7, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants