Skip to content

Conversation

@gfdb
Copy link
Contributor

@gfdb gfdb commented Jun 5, 2024

What does this PR do?

This PR fixes an issue in the SpectrogramDrop forward function.
It is possible and to be expected that n_masks may evaluate to 0 sometimes, for example consider the case when drop_count_low is 0. This is valid, as in this case there should simply be no chunks dropped from the spectrogram. However, if n_masks is 0, mask_len will end up being an empty tensor causing a RuntimeError later on.

Summary of the change

The change is simply to return the spectrogram unchanged in the event that the number of chunks to drop is randomly sampled to be 0.

Before submitting
  • Did you read the contributor guideline?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Does your code adhere to project-specific code style and conventions?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Confirm that the changes adhere to compatibility requirements (e.g., Python version, platform)
  • Review the self-review checklist to ensure the code is ready for review

@mravanelli mravanelli self-requested a review June 5, 2024 18:59
@mravanelli mravanelli added the enhancement New feature or request label Jun 5, 2024
@asumagic
Copy link
Collaborator

asumagic commented Jun 6, 2024

Actually, this is probably deserving of adding tests for this edge case, I'll get to that quickly.

@asumagic asumagic merged commit aa49eab into speechbrain:develop Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants