mindspore.Generator
- class mindspore.Generator[source]
A generator that manages the state of random numbers and provides seed and offset for random functions. When the seed and offset are fixed, random functions generate the same random sequence.
Note
Graph mode does not support the use of multiple generators at the same time for now.
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore as ms >>> from mindspore import Generator >>> generator = Generator() >>> generator.manual_seed(5) >>> print(generator.initial_seed()) 5 >>> state = generator.get_state() >>> generator.seed() >>> generator.set_state(state) >>> print(generator.initial_seed()) 5
- initial_seed()[source]
Return the initial seed of the generator.
- Returns
int, the initial seed of the generator.