Skip to content

Seeding

Utility functions to manage random number generator states.

RngState dataclass #

Dataclass that contains the state of all the numpy/random/torch RNGs.

get classmethod #

get()

Gets the state of the random/numpy/torch random number generators.

set #

set()

Resets the state of the random/numpy/torch random number generators with the contents of self.

fork_rng #

fork_rng()

Forks the RNG, so that when you return, the RNG is reset to the state that it was previously in.

seeded_rng #

seeded_rng(seed: int = 42)

Forks the RNG and seeds the torch, numpy, and random RNGs while inside the block.