-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[WIP] Avoid propagating some input columns when applying Onnx models #4971
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
Closed
antoniovs1029
wants to merge
22
commits into
dotnet:master
from
antoniovs1029:is25onnxColSelectorHarish
Closed
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7be5229
Merged with Harish commit with partial solution:
antoniovs1029 0ac2da1
Merge remote-tracking branch 'upstream/master' into is25onnxColSelect…
antoniovs1029 00a26b2
Revert "Merged with Harish commit with partial solution:"
antoniovs1029 944b066
Revert "Revert "Merged with Harish commit with partial solution:""
antoniovs1029 5a6a1b0
Modified test, because now output schema should be the same as onnx m…
antoniovs1029 4dbdc26
Actually check that the output schema has dropped the columns
antoniovs1029 a1b2b6e
Further modifications to make this work with all the existing tests
antoniovs1029 dfed82e
Remove unnecessary outputschema property on OnnxTransformer
antoniovs1029 816c66f
Move OutputSchema logic to OnnxDataTransform instead of Mapper
antoniovs1029 e928b3b
Added the use of ColumnBindings on OnnxDataTransform
antoniovs1029 d604cf4
Added MYTODO to comments
antoniovs1029 e9f4def
Still not working. GetActive() can't return inputcolumns from 2 diffe…
antoniovs1029 357648e
* Removed ColumnSelectingTransformer from OnnxDataTransform
antoniovs1029 0687f52
Drop columns inside OnnxDataTransformer.Bindings and added comments
antoniovs1029 9191ea9
Revert changes in OnnxTransformTests
antoniovs1029 88bd905
Added comment
antoniovs1029 183ba26
Added test for the different possible cases
antoniovs1029 315aa52
Added comments
antoniovs1029 6759324
Added test for drop columns
antoniovs1029 0fd1557
Fixed mistakes in ColumnSelectingOnnxTestColumnPropagation
antoniovs1029 f73e097
Added side effect test of dropping input columns
antoniovs1029 26e72ec
Updated comments
antoniovs1029 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,12 +365,6 @@ private class ImageDataPoint | |
| [ImageType(Height, Width)] | ||
| public Bitmap Image { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Output of ONNX model. It contains probabilities of all classes. | ||
| /// </summary> | ||
| [ColumnName("softmaxout_1")] | ||
| public float[] Scores { get; set; } | ||
|
|
||
| public ImageDataPoint() | ||
| { | ||
| Image = null; | ||
|
|
@@ -385,6 +379,15 @@ public ImageDataPoint(Color color) | |
| } | ||
| } | ||
|
|
||
| private class OutputImageDataPoint | ||
| { | ||
| /// <summary> | ||
| /// Output of ONNX model. It contains probabilities of all classes. | ||
| /// </summary> | ||
| [ColumnName("softmaxout_1")] | ||
| public float[] Scores { get; set; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Test applying ONNX transform on in-memory image. | ||
| /// </summary> | ||
|
|
@@ -416,7 +419,7 @@ public void OnnxModelInMemoryImage() | |
| // Convert IDataView back to IEnumerable<ImageDataPoint> so that user can inspect the output, column "softmaxout_1", of the ONNX transform. | ||
| // Note that Column "softmaxout_1" would be stored in ImageDataPont.Scores because the added attributed [ColumnName("softmaxout_1")] | ||
| // tells that ImageDataPont.Scores is equivalent to column "softmaxout_1". | ||
| var transformedDataPoints = ML.Data.CreateEnumerable<ImageDataPoint>(onnx, false).ToList(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test needed to be changed because now we're not propagating the input Image column to the output. |
||
| var transformedDataPoints = ML.Data.CreateEnumerable<OutputImageDataPoint>(onnx, false).ToList(); | ||
|
|
||
| // The scores are probabilities of all possible classes, so they should all be positive. | ||
| foreach (var dataPoint in transformedDataPoints) | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Besides the fact that I don't fully like modifying
RowToRowTransformerto make these methods overridable, I don't like the way this looks either. It makes it kinda tricky to have a different transform set the output of this mapper, but it's the only way to go with this approach... it gets weirder because the OnnxDataTransform simply gets the output by accessing members that exist on this mapper.But it's necessary that OnnxTransformer, OnnxTransformer.Mapper, OnnxDataTransform, and OnnxScoringEstimator all give the same output schema, since different code paths will require the output schema from any of these classes. So the entanglement here seems to be necessary. The only alternative is to have each of the classes determine the output schema by themselves, but it might become more difficult to maintain the same code on different places.