rng
Random Number Generator API
This module provides utility functions to set random seed and create random id generators.
Functions:
-
set_random_seed
–Set random seed across libraries: TF, Numpy, Python
-
uniform_id_generator
–Simple generator that yields ids in a uniform manner
-
random_id_generator
–Simple generator that yields ids in a random manner
Functions
set_random_seed
Set random seed across libraries: TF, Numpy, Python
Parameters:
-
seed
(int | None
, default:None
) –Random seed state to use. Defaults to None.
Returns:
-
int
(int
) –Random seed
Source code in neuralspot_edge/utils/rng.py
uniform_id_generator
uniform_id_generator(ids: Iterable[T], repeat: bool = True, shuffle: bool = True) -> Generator[T, None, None]
Simple generator that yields ids in a uniform manner.
Parameters:
-
ids
(Iterable[T]
) –List of ids.
-
repeat
(bool
, default:True
) –Whether to repeat generator. Defaults to True.
-
shuffle
(bool
, default:True
) –Whether to shuffle ids.. Defaults to True.
Note
If repeat is False, generator will stop after yielding all ids once. If shuffle, ids parameter will be modified in place.
Returns:
-
Generator[T, None, None]
–Generator[T, None, None]: Generator
Yields: T: Id
Source code in neuralspot_edge/utils/rng.py
random_id_generator
Simple generator that yields ids in a random manner.
Parameters:
-
ids
(Iterable[T]
) –List of ids
-
weights
(list[int]
, default:None
) –Weights for each id. Defaults to None.
Returns:
-
Generator[T, None, None]
–Generator[T, None, None]: Generator
Yields:
-
T
(T
) –Id