Skip to content

Can not load model from local disk #4868

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
Benknightdark opened this issue Feb 21, 2020 · 7 comments
Closed

Can not load model from local disk #4868

Benknightdark opened this issue Feb 21, 2020 · 7 comments
Assignees
Labels
P3 Doc bugs, questions, minor issues, etc.

Comments

@Benknightdark
Copy link

System information

  • OS Version :windows 10.0.18363
  • .NET Version Info: 3.1.101

Issue

Hi, I used ml.net to build a movie Recommendation System Model, and when I finished build my model, I saved it into my local disk . And then when I load the model from local disk to predict my test data , it appeared this error .
image
Here is my source code :https://github.com/Benknightdark/mlnet

@gvashishtha
Copy link
Contributor

gvashishtha commented Feb 22, 2020

Hm, I was not able to reproduce this error using your source code. What version of ML.NET are you using? Can you try updating to the latest build and see if this resolves your problem?

image

@gvashishtha gvashishtha added the P3 Doc bugs, questions, minor issues, etc. label Feb 22, 2020
@gvashishtha
Copy link
Contributor

I think this issue may have been raised and fixed by @antoniovs1029

See issue here: #4385 and PR here: #4485

@Benknightdark
Copy link
Author

@gvashishtha , I change the ml.net version to 14.0, and resolved my problem. Thanks

@antoniovs1029
Copy link
Member

Just out of curiosity, @Benknightdark , what version where you using before?

@Benknightdark
Copy link
Author

@antoniovs1029 , I use 1.5.0-preview first

@antoniovs1029 antoniovs1029 self-assigned this Feb 25, 2020
@antoniovs1029
Copy link
Member

Hi, I am still looking into this. It should have worked with 1.5.0-preview just as well.

What I've noticed so far, is that previously you tried to use the following:

    <PackageReference Include="Microsoft.ML" Version="1.5.0-preview" />
    <PackageReference Include="Microsoft.ML.Recommender" Version="0.16.0" />

If I, instead, use the most recent nugets for both ML.NET and ML.NET's Recommender, I.e. the following:

    <PackageReference Include="Microsoft.ML" Version="1.5.0-preview" />
    <PackageReference Include="Microsoft.ML.Recommender" Version="0.17.0-preview" />

Then the exception is gone, and it works as expected.

I am still not sure why is this the case, and if this should have worked with using 1.5.0-preview (the latest nuget) along with the Recommender 0.16 (which is not the latest). This also explains why it is working for you when using 1.4 along with Recommender 0.16, since both belong to the same release.

If this should have worked when mixing the releases, then this is actually a bug and I will try to fix it. Thanks for reporting.

@antoniovs1029
Copy link
Member

Hi, @Benknightdark .

So, it seems to me that the only problem here was indeed that you tried to combine Microsoft.ML version 1.5.0-preview with Microsoft.ML.Recommender version 0.16, and those nugets belong to different releases. Since they were different, I'd imagine that when loading the model, they actually registered different versions of the constructor/create methods (one version older, and that's why you got the error message System.InvalidOperationException: Can't load type Microsoft.ML.Trainers.Recommender.MatrixFactorizationModelParameters, because it has both create and constructor methods with the same visibility

ML.NET doesn't support mixing nugets from different releases, so this solves the problem. I will close the issue. Feel free to reopen if you still have problems with this after using the appropriate versions. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 Doc bugs, questions, minor issues, etc.
Projects
None yet
Development

No branches or pull requests

3 participants