-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Error loading LightGBM model #4917
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
Comments
Can you please share your code and dataset to reproduce your problem? thanks Also, what version of Microsoft.ML.LightGbm are you using along with Microsoft.ML 1.4? |
Sadly not, since it business critical data I can't disclose it. About the code I just use the default settings but I do an OneHotEncoding on one field. I'm using the 1.4.0 version of the Microsoft.ML.LightGbm. Please contact me directly through [email protected] and I will send you the code and the dataset for testing purposes |
I wouldn't expect the OneHotEncoding to be related. Can you please list all the Microsoft.ML nugets you're using along with their versions? Recently another user had the same problem, and it was caused because he was combining ML.NET nugets from different releases. Another thing that makes me think you might be using nugets from another release, is because the error message you're seeing ( Also, what kind of LightGBM is it? Binary, multiclass, regression...? |
I tried different things to minimize code and nuget reference and finally I was down to just ML.Net, ML.Net.FastTree and ML.Net.LightGBM and it still didn't work. But when I changed to the ML.Net 1.5.0-preview version it worked perfectly. So it's probably solved by PR #4385. It's a binary LightGBM btw. Thanks for the help! |
System information
Issue
Build and trained a model with FastTree, saved it and finally load it and all worked. Changed to LightGBM and got an error when I try to load it.
The error is following:
InvalidOperationException: Can't load type Microsoft.ML.IPredictorProducing`1[System.Single], because it has both create and constructor methods with the same visibility. Please indicate which one should be used by changing either the signature or the visibility of one of them.
Source code / logs
InvalidOperationException: Can't load type Microsoft.ML.IPredictorProducing`1[System.Single], because it has both create and constructor methods with the same visibility. Please indicate which one should be used by changing either the signature or the visibility of one of them.
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 Microsoft.ML.ModelOperationsCatalog.Load(String filePath, DataViewSchema& inputSchema)
This exception was originally thrown at this call stack:
Microsoft.ML.Runtime.ComponentCatalog.TryGetIniters(System.Type, System.Type, System.Type[], out System.Reflection.MethodInfo, out System.Reflection.ConstructorInfo, out System.Reflection.MethodInfo, out bool)
Microsoft.ML.Runtime.ComponentCatalog.RegisterAssembly(System.Reflection.Assembly, bool)
Microsoft.ML.ModelLoadContext.EnsureLoaderAssemblyIsRegistered(Microsoft.ML.Runtime.ComponentCatalog)
Microsoft.ML.ModelLoadContext.TryLoadModelCore<TRes, TSig>(Microsoft.ML.Runtime.IHostEnvironment, out TRes, object[])
Microsoft.ML.ModelLoadContext.TryLoadModel<TRes, TSig>(Microsoft.ML.Runtime.IHostEnvironment, out TRes, Microsoft.ML.RepositoryReader, Microsoft.ML.Repository.Entry, string, object[])
Microsoft.ML.ModelLoadContext.LoadModel<TRes, TSig>(Microsoft.ML.Runtime.IHostEnvironment, out TRes, Microsoft.ML.RepositoryReader, Microsoft.ML.Repository.Entry, string, object[])
Microsoft.ML.ModelLoadContext.LoadModelOrNull<TRes, TSig>(Microsoft.ML.Runtime.IHostEnvironment, out TRes, Microsoft.ML.RepositoryReader, string, object[])
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:
InvalidOperationException: Can't load type Microsoft.ML.IPredictorProducing`1[System.Single], because it has both create and constructor methods with the same visibility. Please indicate which one should be used by changing either the signature or the visibility of one of them.
The text was updated successfully, but these errors were encountered: