torchsig.utils.random.Seedable¶
- class torchsig.utils.random.Seedable(seed: int | None = None, parent=None, **kwargs)[source]¶
Bases:
objectA class/interface representing objects capable of accessing random numbers and being seeded. Stores an inernal random number generator object. Can be seeded with the Seedable.seed(seed_value : long) function. Two Seedable objects with the same seed will always generate/access the same random values in the same order. Containing or composing Seedable objects are generally responsible for seeding contained or composed Seedable objects.
Methods
Add parent Seedable object and set up RNGs accordingly
Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds
Seed number generators with given seed.
Initialize torch and numpy number generators, and update its children.
Update numpy and torch number generators with parent seed
- __init__(seed: int | None = None, parent=None, **kwargs)[source]¶
Initializes seedable object with self.seed = seed; if a parent Seedable object is passed in, they will share random number generators, and the seed argument will not be used
- seed(seed: int) None[source]¶
Seed number generators with given seed.
- Parameters:
seed (int) – Seed to use.