Added support for inserting batch dimension in inputs in TensorFlow. #2935
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 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.