Skip to content
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

Merged
merged 4 commits into from
Feb 19, 2020
Merged

Fixed output schema of OnnxTransformer #4849

merged 4 commits into from
Feb 19, 2020

Conversation

harishsk
Copy link
Contributor

@harishsk harishsk commented Feb 17, 2020

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

@@ -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.
Copy link
Member

@ganik ganik Feb 19, 2020

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

Copy link
Contributor Author

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)));
Copy link
Member

@ganik ganik Feb 19, 2020

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need CopyColumns either.


In reply to: 381300171 [](ancestors = 381300171)

Copy link
Member

@ganik ganik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@harishsk harishsk merged commit 051ff17 into dotnet:master Feb 19, 2020
@harishsk harishsk deleted the onnxOutputSchemaFix branch April 21, 2020 23:59
@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
None yet
Projects
None yet
2 participants