use scale=1.0 in floats_tensor called in speech model testers#17007
Merged
ydshieh merged 1 commit intohuggingface:mainfrom Apr 29, 2022
Merged
use scale=1.0 in floats_tensor called in speech model testers#17007ydshieh merged 1 commit intohuggingface:mainfrom
ydshieh merged 1 commit intohuggingface:mainfrom
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
|
|
||
| def prepare_config_and_inputs(self): | ||
| input_values = floats_tensor([self.batch_size, self.seq_length], self.vocab_size) | ||
| input_values = floats_tensor([self.batch_size, self.seq_length], scale=1.0) |
Contributor
There was a problem hiding this comment.
wow good catch!
patrickvonplaten
approved these changes
Apr 29, 2022
Contributor
patrickvonplaten
left a comment
There was a problem hiding this comment.
You're 100% right - this was indeed a bad copy paste!
Contributor
|
Thanks for fixing all the tests! |
sgugger
approved these changes
Apr 29, 2022
Collaborator
sgugger
left a comment
There was a problem hiding this comment.
Nice fix! Thanks a lot!
stevhliu
pushed a commit
to stevhliu/transformers
that referenced
this pull request
May 3, 2022
…gface#17007) Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
elusenji
pushed a commit
to elusenji/transformers
that referenced
this pull request
Jun 12, 2022
…gface#17007) Co-authored-by: ydshieh <ydshieh@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.
What does this PR do?
Fix the failure of
Speech2TextModelTest.test_pt_tf_model_equivalence. This is caused bytransformers/tests/speech_to_text/test_modeling_speech_to_text.py
Lines 134 to 136 in e6f00a1
where the
input_featuresget a large magnitude of1e2(fromself.vocab_size=99).(probably this happens because we just copied the
input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)from NLP models?)I changed it to
scale=1.0, but need @patrickvonplaten's expertise to make sure there was no particular reason to useself.vocab_size.Details
Current speech model testers have
The
self.vocab_sizeargument is thescale, so the generated dummyinput_valueshas the magnitude ofself.vocab_size.For
Speech2TextModelTester, we havevocab_size=99.Furthermore,
Speech2TextEncoderhastransformers/src/transformers/models/speech_to_text/modeling_speech_to_text.py
Line 705 in e6f00a1
and from the tester's
hidden_size=16,we getembed_scale=4.The
input_featuresgoes through the conv layer(s) and being scaled:transformers/src/transformers/models/speech_to_text/modeling_speech_to_text.py
Lines 767 to 768 in e6f00a1
On
CPUhowever, the conv layers of PT/TF gives diff. with a magnitude of1e-7for input values with 1s. So with the above 2 scalings, this error becomes4e-5, and the PT/TF equiv. test fails.