Skip to content
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

[Wav2Vec2] Fix mask_feature_prob #13921

Merged
merged 2 commits into from
Oct 7, 2021

Conversation

patrickvonplaten
Copy link
Contributor

What does this PR do?

When using mask_feature_prob > 0 it's important that the attention_mask is not passed as the attention_mask's dimension is [batch_size, sequence_length]. Since attention_mask = 1 vectors are padded anyways it doesn't matter whether some of those vectors are zero-ed out or not. Thus we should just never pass attention_mask for mask_feature_prob > 0.
We however need it for mask_time_prob since mask_time_prob is used for Wav2Vec2ForPretraining where the created outputs will be used as labels.

@patrickvonplaten patrickvonplaten linked an issue Oct 7, 2021 that may be closed by this pull request
4 tasks
@patrickvonplaten
Copy link
Contributor Author

@anton-l - feel free to merge if the change is OK for you :-)

@@ -433,6 +434,52 @@ def _mock_init_weights(self, module):
if hasattr(module, "masked_spec_embed") and module.masked_spec_embed is not None:
module.masked_spec_embed.data.fill_(3)

def test_mask_feature_prob_ctc(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test was failing before

@anton-l
Copy link
Member

anton-l commented Oct 7, 2021

Makes sense, thanks for adding the tests too! 👍

@anton-l anton-l merged commit 0f5488f into huggingface:master Oct 7, 2021
@patrickvonplaten patrickvonplaten deleted the fix_wav2vec2_mask_prob branch October 7, 2021 16:08
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error using SpecAugment feature masking in Wav2Vec 2.0
2 participants