-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Error on prediction with LSTM Model in ONNX Format in ML.Net #5273
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
Hi, @ladodc . I believe this is a duplicate of dotnet/machinelearning-samples#828 So I'll close that issue, to continue the discussion here. Can you please share the full stack trace of your exception? Also, if you're able to share your At first look, I think the problem is that you're not correctly setting the input for your onnx model. Unfortunately, there's no general advice I could provide on how you should do this, since it will depend on the input expected by you I'd think the problem is that you need to reshape your input In particular when working with Onnx, I gave this advice to a user that was having a similar problem like you (although in their case the problem was somewhat more complicated, as they were dealing with input images, and also needing to reshape that input). So you can check that advice to get an idea of how to use Note: I'm not sure on how reshape should be done if the onnx model expects a dimension of size |
Hi Antonio, thanks for your response. I will try to follow your recommendation. Meanwhile I can give you my ONNX Model to experiment with this. |
Hi, @ladodc . So, after looking closer into this, it turns out that the Also, after playing around I realized that there's no need for the public class InputData
{
[ColumnName("input_layer")]
[VectorType(3,7)]
public float[,] X { get; set; } // Using 3x7 arrays
} It should be: public class InputData
{
[ColumnName("input_layer")]
[VectorType(3,7)] // This could also be (1,3,7), it seems it doesn't matter
public float[] X { get; set; } // Using 1-D arrays of size 21
}
...
new InputData() { X = new float[] { 1, 2, 3, 4, 5, 6, 7 , 1, 2, 3, 4, 5, ... The info of the shape is already set by the After making the change above, I was able to run your code without problems, and got a predictions array. Still, the prediction was "0"... I tried modifying the values of the input vector, and I always got a prediction = "0". I did debug this, and it seems everything is working fine in the OnnxTransformer, so I'm not sure: Is this expected? Is your model supposed to return 0 with the data you provided?. I'm not yet sure what your model is supposed to do (the sigmoid at the end that returns 1 float, makes me think this is a binary classification problem), so please let us know if this expected behavior. If it's not expected, then please let us know what would be the expected behavior, and if possible any code you used to create the model, so that I can further investigate if this is a problem in ML.NET, in OnnxRuntime, or in your model. Thanks! 😄 |
I've opened a PR updating the docs of Please, feel free to reopen the issue if you find that the behavior of running the Onnx model isn't as expected, and provide the info requested on my last comment if this is the case. Thanks. 😄 |
System information
Issue
I would like to predict Values with my LSTM Model in ONNX Format. I am struggling on data input for my ONNX Model in my ML.NET project. When I run my code, I get an Exception: System.NullReferenceException: 'Object reference not set to an instance of an object.' on prediction. The input data is just dummy. I am trying to find out, how to input data in form (None,3,7) as expected from LSTM Model. LSTM Model ist attached. Can someone help me, what I am doing wrong?
Why I get exception or how to deliver data for my ONNX Model.
The text was updated successfully, but these errors were encountered: