Shortcuts

seed

Functions

pl_worker_init_function

The worker_init_fn that Lightning automatically adds to your dataloader if you previously set set the seed with seed_everything(seed, workers=True).

reset_seed

Reset the seed to the value that pytorch_lightning.utilities.seed.seed_everything() previously set.

seed_everything

Function that sets seed for pseudo-random number generators in: pytorch, numpy, python.random In addition, sets the following environment variables:

Helper functions to help with reproducibility of models.

pytorch_lightning.utilities.seed.pl_worker_init_function(worker_id, rank=None)[source]

The worker_init_fn that Lightning automatically adds to your dataloader if you previously set set the seed with seed_everything(seed, workers=True).

See also the PyTorch documentation on randomness in DataLoaders.

Return type

None

pytorch_lightning.utilities.seed.reset_seed()[source]

Reset the seed to the value that pytorch_lightning.utilities.seed.seed_everything() previously set.

If pytorch_lightning.utilities.seed.seed_everything() is unused, this function will do nothing.

Return type

None

pytorch_lightning.utilities.seed.seed_everything(seed=None, workers=False)[source]

Function that sets seed for pseudo-random number generators in: pytorch, numpy, python.random In addition, sets the following environment variables:

  • PL_GLOBAL_SEED: will be passed to spawned subprocesses (e.g. ddp_spawn backend).

  • PL_SEED_WORKERS: (optional) is set to 1 if workers=True.

Parameters
  • seed (Optional[int]) – the integer value seed for global random state in Lightning. If None, will read seed from PL_GLOBAL_SEED env variable or select it randomly.

  • workers (bool) – if set to True, will properly configure all dataloaders passed to the Trainer with a worker_init_fn. If the user already provides such a function for their dataloaders, setting this argument will have no influence. See also: pl_worker_init_function().

Return type

int

Read the Docs v: latest
Versions
latest
stable
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.8
1.3.7
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.10
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3
0.4.9
ipynb-update
docs-search
Downloads
html
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.