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

Fix randomness in CutMix transform #1316

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Fix randomness in CutMix transform #1316

merged 2 commits into from
Apr 3, 2024

Conversation

pzelasko
Copy link
Collaborator

@pzelasko pzelasko commented Apr 3, 2024

No description provided.

@pzelasko pzelasko added this to the v1.23.0 milestone Apr 3, 2024
@pzelasko pzelasko mentioned this pull request Apr 3, 2024
noise_cuts = DummyManifest(CutSet, begin_id=100, end_id=102)

# called twice on the same input, expecting different results
tfnm = CutMix(noise_cuts, snr=None, p=1.0, seed=0, preserve_id=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: tnfm

@pzelasko pzelasko merged commit 1b68036 into master Apr 3, 2024
9 checks passed
@pzelasko pzelasko deleted the feature/fix-cut-mix branch April 3, 2024 18:05
tfnm = CutMix(noise_cuts, snr=None, p=1.0, seed=0, preserve_id=True)
out1 = tfnm(speech_cuts)
out2 = tfnm(speech_cuts)
assert list(out1) != list(out2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this test. I ran this using v1.17 which is stateless, but I still got different outputs (i.e., out1 and out2 are different). This is counterintuitive because CutMix passes the same seed in every __call__ to cuts.mix. can you please help me understand this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It used CutSet.sample which was not seeded and used the global RNG. If I start any new library from scratch I’ll keep it in mind to have a methodical approach to RNG handling from the beginning.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, you're right. I forgot about that. Thanks again.

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.

None yet

2 participants