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

[WhisperModel] fix bug in reshaping labels #21653

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

jonatasgrosman
Copy link
Contributor

Currently, in the Whisper model's forward pass, the target labels are reshaped using the view method before being passed into the loss function:

loss = loss_fct(lm_logits.view(-1, self.config.vocab_size), labels.view(-1))

The view method requires the Torch Tensor to be contiguous, and certain operations are commonly performed on the labels that might cause them not to be contiguous.

So using the view can cause problems during model training. This issue has already been fixed on another model by the @sanchit-gandhi in a PR, and I'm just replicating the same solution (using reshape() instead of view()) here for the Whisper model.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 16, 2023

The documentation is not available anymore as the PR was closed or merged.

@sgugger
Copy link
Collaborator

sgugger commented Feb 16, 2023

Also cc @ArthurZucker

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@ArthurZucker ArthurZucker merged commit 96d4fa4 into huggingface:main Feb 16, 2023
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.

4 participants