mindspore.dataset.config.set_seed

mindspore.dataset.config.set_seed(seed)

Set the seed so the random generated number will be fixed for deterministic results.

Note

This set_seed function sets the seed in the Python random library and numpy.random library for deterministic Python augmentations using randomness. This set_seed function should be called when iterator is created to reset the random seed.

Parameters

seed (int) – Random number seed. It is used to generate deterministic random numbers.

Raises
  • TypeError – If seed isn’t of type int.

  • ValueError – If seed < 0 or seed > UINT32_MAX(4294967295).

Examples

>>> # Set a new global configuration value for the seed value.
>>> # Operations with randomness will use the seed value to generate random values.
>>> import mindspore.dataset as ds
>>> ds.config.set_seed(1000)