-
Notifications
You must be signed in to change notification settings - Fork 3
Use Generator to control the randomness for each backend dataloader
#45
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cdf67cf
Use `Generator` to control the randomness for each backend dataloader
BirkhoffG 55543fb
Fix class init args
BirkhoffG 84ef697
Fix typo
BirkhoffG ed78af7
Fix typing
BirkhoffG 13aeba5
Add GeneratorType
BirkhoffG 9ffd303
Fix none typing
BirkhoffG d58e6b5
Add generator parameter to DataLoader for random seed control
BirkhoffG 405ba43
Add generator tests for DataLoader across integration tests
BirkhoffG 8f4414b
Fix `GeneratorType`
BirkhoffG f031b23
Fix GeneratorType by using Union
BirkhoffG 0438414
Fix generator type check to ensure torch is available before instance…
BirkhoffG 3d63f9b
Fix tf_test.py
BirkhoffG f519bf2
Fix generator tests to use jax.tree_util for tree operations
BirkhoffG ee1214f
Move GeneratorType to `types.py`
BirkhoffG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -253,20 +253,19 @@ | |||||
| "\n", | ||||||
| " if generator is None:\n", | ||||||
| " self._seed = get_config().global_seed\n", | ||||||
| " elif isinstance(generator, jax.Array):\n", | ||||||
| " self._jax_generator = generator\n", | ||||||
| " elif isinstance(generator, torch.Generator):\n", | ||||||
| " self._torch_generator = generator\n", | ||||||
| " elif isinstance(generator, jax.Array):\n", | ||||||
| " self._jax_generator = generator\n", | ||||||
| " else:\n", | ||||||
| " raise ValueError(f\"generator=`{generator}` is invalid. Must be either a `jax.random.PRNGKey` or a `torch.Generator`.\")\n", | ||||||
| " \n", | ||||||
| " if self._seed is None and self._torch_generator is not None:\n", | ||||||
| " self._seed = self._torch_generator.initial_seed()\n", | ||||||
| "\n", | ||||||
| " def seed(self) -> int:\n", | ||||||
| " def seed(self) -> Optional[int]:\n", | ||||||
| " \"\"\"The initial seed of the generator\"\"\"\n", | ||||||
| " if self._seed is None:\n", | ||||||
| " raise ValueError(\"The seed is not specified. Please set the seed using `manual_seed()` or pass a generator.\")\n", | ||||||
| " # TODO: the seed might not be initizalized if the generator is a `jax.random.PRNGKey`\n", | ||||||
|
||||||
| " # TODO: the seed might not be initizalized if the generator is a `jax.random.PRNGKey`\n", | |
| " # TODO: the seed might not be initialized if the generator is a `jax.random.PRNGKey`\n", |
Oops, something went wrong.
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 was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word 'initizalized' should be corrected to 'initialized' for clarity.