Fixed output schema of OnnxTransformer#4849
Merged
harishsk merged 4 commits intodotnet:masterfrom Feb 19, 2020
harishsk:onnxOutputSchemaFix
Merged
Fixed output schema of OnnxTransformer#4849harishsk merged 4 commits intodotnet:masterfrom harishsk:onnxOutputSchemaFix
harishsk merged 4 commits intodotnet:masterfrom
harishsk:onnxOutputSchemaFix
Conversation
ganik
reviewed
Feb 19, 2020
| @@ -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. | |||
Member
There was a problem hiding this comment.
Are these comments still valid? Do we do hand correction now? #Resolved
Contributor
Author
There was a problem hiding this comment.
The comments are not valid. I have removed them in the next commit.
In reply to: 381300021 [](ancestors = 381300021)
ganik
reviewed
Feb 19, 2020
| // 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))); |
Member
There was a problem hiding this comment.
CopyColumns("Score", "Score") [](start = 37, length = 29)
Do we need CopyColumn now? #Resolved
Contributor
Author
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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