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

Change perturb rng for reproducing results easily #6042

Merged
merged 5 commits into from
Feb 17, 2023
Merged

Conversation

fayejf
Copy link
Collaborator

@fayejf fayejf commented Feb 16, 2023

What does this PR do?

Change perturb rng for reproducing results easily

Collection: ASR

Changelog

  • Remove Random number generator and use int rng and seed.
  • update tutorial.

Usage

You can use rng (int) for Perturbations.

 augmentor:
          silence:
            prob: 0.8
            min_start_silence_secs: 0
            max_start_silence_secs: 5
            min_end_silence_secs: 0
            max_end_silence_secs: 5
            rng: 42 # default is None**

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@github-actions github-actions bot added the ASR label Feb 16, 2023
Signed-off-by: fayejf <[email protected]>
@fayejf fayejf changed the title Change perturb rng for reproducing result easily Change perturb rng for reproducing results easily Feb 16, 2023
@fayejf fayejf marked this pull request as ready for review February 16, 2023 22:30
Signed-off-by: fayejf <[email protected]>
Copy link
Collaborator

@titu1994 titu1994 left a comment

Choose a reason for hiding this comment

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

Thanks !

@stevehuang52 stevehuang52 merged commit d0119f5 into main Feb 17, 2023
@fayejf fayejf deleted the perturb_seed branch February 17, 2023 20:01
titu1994 pushed a commit to titu1994/NeMo that referenced this pull request Mar 24, 2023
* add random seed in perturb

Signed-off-by: fayejf <[email protected]>

* small update

Signed-off-by: fayejf <[email protected]>

* update evaluator config

Signed-off-by: fayejf <[email protected]>

* update tutorial

Signed-off-by: fayejf <[email protected]>

* update add_noise

Signed-off-by: fayejf <[email protected]>

---------

Signed-off-by: fayejf <[email protected]>

for i in range(n_additions):
noise_dur = self._rng.uniform(0.0, max_noise_dur)
start_time = self._rng.uniform(0.0, noise.duration)
noise_dur = random.uniform(0.0, max_noise_dur)
Copy link
Contributor

@vadimkantorov vadimkantorov Apr 9, 2023

Choose a reason for hiding this comment

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

do I understand correctly that the random state is now global? is it more reproducible with global state rather than local? typically local state is preferrable, no?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes the random state is now global (if no specific random seed is provided for each perturb), and from the results it seems that now it can fully reproduce the same results with the same random seed.

Could @fayejf please provide more explanations/details?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, maybe it now reproduces, but it's then more brittle in how it interacts with other code potentially changing the global random state or resetting it...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your question and suggestion. In which case do you think it will potentially change the global random state or reset it? Could you elaborate more please?

Copy link
Contributor

@vadimkantorov vadimkantorov Apr 11, 2023

Choose a reason for hiding this comment

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

I meant that if some other aug in the pipeline also resets the seed, then it might break the reproducibility of this aug because they both affect the same global state.

In other places maybe I saw the other way around and torch rng generators are introduced as explicit arguments to fully control the randomness (e.g. this is being discussed in torchvision)

But it was just a question :) (based on some general aug pipeline experience in other contexts) I haven't read very deeply the NeMo pipeline, and I don't have good, well-based NeMo-specific arguments etc...

hsiehjackson pushed a commit to hsiehjackson/NeMo that referenced this pull request Jun 2, 2023
* add random seed in perturb

Signed-off-by: fayejf <[email protected]>

* small update

Signed-off-by: fayejf <[email protected]>

* update evaluator config

Signed-off-by: fayejf <[email protected]>

* update tutorial

Signed-off-by: fayejf <[email protected]>

* update add_noise

Signed-off-by: fayejf <[email protected]>

---------

Signed-off-by: fayejf <[email protected]>
Signed-off-by: hsiehjackson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants