dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
9.05k stars 1.89k forks source link

load ONNX model(RNN[LSTM]) can not work #6241

Closed zhangfeibao closed 2 years ago

zhangfeibao commented 2 years ago

System Information

I got the onnx model from tf2. The model infomation is: image I load the onnx model follow the document.

private static ITransformer GetPredictionPipeline(MLContext mlContext)
{
    var inputColumns = new string[]
    {
        "model"
    };

    var outputColumns = new string[] { "dense" };

    var onnxPredictionPipeline =
        mlContext
        .Transforms
        .ApplyOnnxModel(
        outputColumnNames: outputColumns,
        inputColumnNames: inputColumns,
        ONNX_MODEL_PATH);

    var emptyDv = mlContext.Data.LoadFromEnumerable(new OnnxInput[] {});    //the line will throw the exception

    return onnxPredictionPipeline.Fit(emptyDv);
}

when i ran the app,I got the exception at the line.

System.InvalidOperationException:“Input shape mismatch: Input 'model' has shape 1,50,4, but input data is of length 1.”

I have tryed many time to resove the problem.but it just can't work!

luisquintanilla commented 2 years ago

@zhangfeibao what does your ONNXInput class look like?

ghost commented 2 years ago

This issue has been marked needs-author-action and may be missing some important information.

ghost commented 2 years ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

ghost commented 2 years ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.