mindspore.ops.randint

View Source On AtomGit
mindspore.ops.randint(low, high, size, seed=None, *, dtype=None)[source]

Return a tensor whose elements are random integers in the range of [ low , high ) .

Warning

  • Non-backward-compatible change after version 2.9.0: the signature will change to randint(low=0, high, size, *, generator=None, dtype=None), and seed will be removed.

  • The Ascend backend does not support the reproducibility of random numbers, so the seed parameter has no effect.

Parameters
  • low (int) – Start value of interval.

  • high (int) – End value of interval.

  • size (tuple) – Shape of the output tensor.

  • seed (int, optional) – Random seed, must be non-negative. Default None .

Keyword Arguments

dtype (mindspore.dtype, optional) – The data type returned. Default None .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> print(mindspore.ops.randint(1, 10, (2,3)))
[[4 9 7]
 [9 1 2]]