mygrad.random.seed#

mygrad.random.seed(seed_number)[source]#

Seed the generator.

Simply used NumPy’s random state - i.e. this is equivalent to numpy.random.seed.

Parameters:
seed_numberint or 1-d array_like, optional

Seed for RandomState. Must be convertible to 32 bit unsigned integers.

Examples

>>> from mygrad.random import seed, random
>>> seed(0)
>>> random((2, 4))
Tensor([[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
        [0.4236548 , 0.64589411, 0.43758721, 0.891773  ]])
>>> seed(1)
>>> random((2, 4))
Tensor([[4.17022005e-01, 7.20324493e-01, 1.14374817e-04, 3.02332573e-01],
        [1.46755891e-01, 9.23385948e-02, 1.86260211e-01, 3.45560727e-01]]
>>> seed(0)
>>> random((2,4))
Tensor([[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
        [0.4236548 , 0.64589411, 0.43758721, 0.891773  ]])