-
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
Added support for inserting batch dimension in inputs in TensorFlow. #2935
Conversation
Are you sure about that? I though we properly handle variable length tensors, and that [-1,244,244,3] would be casted to [1,244,244,3] and we internally would stretch our image [244,244,3] into it. Then I look into it - input layer had [1,244,244,3] and that was reason why we can't handle it, since it's not variable length, it's fixed 4 dimensional tensor instead of tensor of variable length. |
Yes, the input is variable length with unknown shape. However, model actually wants input in [B, H, W, C] format and this shape cannot be inferred automatically. In reply to: 472221487 [](ancestors = 472221487) |
Codecov Report
@@ Coverage Diff @@
## master #2935 +/- ##
==========================================
- Coverage 72.19% 72.18% -0.01%
==========================================
Files 796 796
Lines 142005 142025 +20
Branches 16044 16047 +3
==========================================
+ Hits 102514 102522 +8
- Misses 35114 35123 +9
- Partials 4377 4380 +3
|
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 PR fixes #2778.
It is difficult to induce shape of the inputs from the data or model when the model accepts input of any shape but internal operators requires the input in particular shape. This is the problem with the inception model available at the following location.
https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip
The model takes input data of any shape. There is a convolution layer just after the input which requires 4-D input. The first dimension for Conv2D operation in TensorFlow is the batch dimension. That's causing failure of samples in #2778. The ML.NET input is [224, 244, 3] while convolution layer in the above model requires [-1, 224, 224, 3]. The ultimate solution to this problem is to have reshape transform #765.
However, it will take time implement. To unblock #2778, the temporary solution implemented here is to add a parameter in options class or other public interfaces called “AddBatchDimensionInput”. When user set it to true, batch dimension would be added to the inputs otherwise not.
NOTE: Once we have the
ReshapeTransform
. This change needs to be reverted.