mindspore.ops.randint

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

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

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

  • high (int) – End value of interval.

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

  • seed (int, optional) – Random seed, must be greater or equal to 0. Default: None , and 0 will be used.

Keyword Arguments

dtype (mindspore.dtype, optional) – Designated tensor dtype, it must be int type. If None , mindspore.int64 will be used. Default: None .

Returns

Tensor, with the designated shape and dtype, filled with random integers from low (inclusive) to high (exclusive).

Raises
Supported Platforms:

Ascend GPU CPU

Examples

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