mindspore.ops.randint
- 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
- Keyword Arguments
dtype (
mindspore.dtype
, optional) – Designated tensor dtype, it must be int type. IfNone
, 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
TypeError – seed is not a non-negative integer.
TypeError – size is not a tuple.
TypeError – low or high is not an integer.
ValueError – If dtype is not a mstype.int_type.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> from mindspore import ops >>> print(ops.randint(1, 10, (2,3))) [[4 9 7] [9 1 2]]