Simplify, correct, and add validation for GRU/LSTM and friends#659
Merged
fdwr merged 8 commits intowebmachinelearning:mainfrom May 2, 2024
inexorabletash:gru-lstm-validation-fixes
Merged
Simplify, correct, and add validation for GRU/LSTM and friends#659fdwr merged 8 commits intowebmachinelearning:mainfrom inexorabletash:gru-lstm-validation-fixes
fdwr merged 8 commits intowebmachinelearning:mainfrom
inexorabletash:gru-lstm-validation-fixes
Conversation
- A couple of places were comparing a rank vs. an expected dimension (e.g. "rank is not equal to 3 * hiddenSize"). Fix these! - Rather than validating for example validating that rank = 2, shape[0] = N and shape[1] = M, just compare shape against « N, M ». - While doing the above, several arguments had their data type and rank validated, but only some of the dimensions. Make this consistent across the ops - at least, matching the existing prose.
Contributor
Author
|
The fun never stops! I may be wrong and the missing validation is intentional - e.g. for lstmCell, cellState's data type and rank are validated, but not the actual dimensions called out in the prose ("The 2-D input cell state tensor of shape [batchSize, hiddenSize].") |
huningxin
reviewed
Apr 28, 2024
Contributor
Author
|
Thanks for the close look, @huningxin - all those weight/recurrentWeight/hiddenSize/inputSize blur together after a while. |
Contributor
Author
|
I noticed one more case where this could be applied: instanceNormalization - bundled it into this PR since it was on topic. Done in fcf0479 |
Collaborator
This is nice and concise. |
github-actions bot
added a commit
that referenced
this pull request
May 2, 2024
SHA: aa5fac9 Reason: push, by fdwr Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Some steps in gruCell() were comparing a rank vs. an expected dimension (e.g. "rank is not equal to 3 * hiddenSize"). Fix these!
Rather than validating for example that rank = 2, shape[0] = N and shape[1] = M, just compare shape against « N, M ». This also implicitly fixes places that were inspecting shape[x] without validating the rank first. Done for: batchNormalization(), conv2d(), convTranspose2d(), gru(), gruCell(), lstm(), lstmCell().
Some places did validate data type and rank, but only some or none of the dimensions. Make this consistent across the ops - at least, matching the existing prose. Done for gru(), gruCell(), instanceNormalization(), lstm(), lstmCell().
Preview | Diff