Repository navigation
augmentation: Fix AmplitudeScale crashing on default random_state + more - #1021
Merged
bruAristimunha merged 4 commits intoMay 19, 2026
Merged
Conversation
… on numpy RandomState Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
bruAristimunha
approved these changes
May 19, 2026
Collaborator
|
many thanks @tayal-sarthak, good PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are two unrelated drive-by fixes batched together.
1. AmplitudeScale class is dead on arrival
calling AmplitudeScale(probability=1.0) on a batch raises RuntimeError: manual_seed expected a long, but got numpy.random.mtrand.RandomState. the documented random_state=None default also blows up the same way (manual_seed expected a long, but got NoneType).
The root cause sits in amplitude_scale in braindecode/augmentation/functional.py. it builds a torch.Generator and feeds whatever the caller passed into manual_seed, which only accepts a python int. Transform.init wraps random_state via check_random_state which produces a numpy RandomState, and that numpy RandomState gets handed straight in via get_augmentation_params. the class path was never exercised before, which is how the regression slipped in.
repro:
The fix swaps the torch.Generator path with check_random_state + rng.uniform + torch.as_tensor, the same idiom used by every sibling function in this file (gaussian_noise, channels_shuffle, sensors_rotation, band_rotation, ...). int seeds keep reproducibility, numpy RandomState works, None works. docstring tightened to match what the function accepts.
2. broken 404 author link in docs
(viewable inside of the code for jon-dan Thank you!
closes #1017