-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fixed output schema of OnnxTransformer #4849
Conversation
@@ -109,7 +104,7 @@ public void SaveOnnxModelLoadAndScoreKMeans() | |||
// TODO #2980: ONNX outputs don't match the outputs of the model, so we must hand-correct this for now. | |||
// TODO #2981: ONNX models cannot be fit as part of a pipeline, so we must use a workaround like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments still valid? Do we do hand correction now? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments are not valid. I have removed them in the next commit.
In reply to: 381300021 [](ancestors = 381300021)
@@ -109,7 +104,7 @@ public void SaveOnnxModelLoadAndScoreKMeans() | |||
// TODO #2980: ONNX outputs don't match the outputs of the model, so we must hand-correct this for now. | |||
// TODO #2981: ONNX models cannot be fit as part of a pipeline, so we must use a workaround like this. | |||
var onnxWorkaroundPipeline = onnxModel.Append( | |||
mlContext.Transforms.CopyColumns("Score", "Score.onnx").Fit(onnxModel.Transform(data))); | |||
mlContext.Transforms.CopyColumns("Score", "Score").Fit(onnxModel.Transform(data))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CopyColumns("Score", "Score") [](start = 37, length = 29)
Do we need CopyColumn now? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a long standing issue about Onnx in ML.NET that the output variables of the onnx graph show up as columns with different names in the output schema of OnnxTransformer. After much investigation, it turns out that the output variables in the Onnx graph cannot be fixed because it is not possible to specify in onnx which particular node you want your output variable to be connected to.
This fix, adds a known ".output" suffix to all Onnx models exported from ML.NET. And when reading a model, if the model was exported from ML.NET, it recognizes the suffix, strips it and maps it back to the input column.
As a result of fixing this PR also contains updates to the tests and baseline files.
Fixes #2980. Fixes #2981