mindspore.ops.randint_like
- mindspore.ops.randint_like(input, low, high, seed=None, *, dtype=None)[source]
Returns a tensor with the same shape as Tensor input 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
, the same dtype of input will be applied. 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 – 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 Tensor, ops >>> a = Tensor([[1, 2, 3], [3, 2, 1]]) >>> print(ops.randint_like(a, 1, 10)) [[4 9 7] [9 1 2]]