# randint_like¶

paddle. randint_like ( x, low=0, high=None, dtype=None, name=None ) [source]

This OP returns a Tensor filled with random integers from a discrete uniform distribution in the range [`low`, `high`), with the same shape as `x`. (use `dtype` if `dtype` is not None) If `high` is None (the default), the range is [0, `low`).

Parameters
• x (Tensor) – The input tensor which specifies shape. The dtype of `x` can be bool, int32, int64, float16, float32, float64.

• low (int) – The lower bound on the range of random values to generate. The `low` is included in the range. If `high` is None, the range is [0, `low`). Default is 0.

• high (int, optional) – The upper bound on the range of random values to generate, the `high` is excluded in the range. Default is None (see above for behavior if high = None). Default is None.

• dtype (str|np.dtype, optional) – The data type of the output tensor. Supported data types: bool, int32, int64, float16, float32, float64. If `dytpe` is None, the data type is the same as x’s data type. Default is None.

• name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

A Tensor filled with random integers from a discrete uniform distribution in the range [`low`, `high`), with `shape` and `dtype`.

Return type

Tensor

Examples

```import paddle

# example 1:
# dtype is None and the dtype of x is float16
print(out1)
print(out1.dtype)
# [[0, -3]]  # random

# example 2:
# dtype is None and the dtype of x is float32
print(out2)
print(out2.dtype)
# [[0, -3]]  # random

# example 3:
# dtype is None and the dtype of x is float64
print(out3)
print(out3.dtype)
# [[0, -3]]  # random

# example 4:
# dtype is None and the dtype of x is int32
print(out4)
print(out4.dtype)
# [[0, -3]]  # random

# example 5:
# dtype is None and the dtype of x is int64
print(out5)
print(out5.dtype)
# [[0, -3]]  # random

# example 6:
# dtype is float64 and the dtype of x is float32
out6 = paddle.randint_like(x, low=-5, high=5, dtype="float64")
print(out6)
print(out6.dtype)
# [[0, -1]]  # random

# example 7:
# dtype is bool and the dtype of x is float32
out7 = paddle.randint_like(x, low=-5, high=5, dtype="bool")
print(out7)
print(out7.dtype)
# [[0, -1]]  # random

# example 8:
# dtype is int32 and the dtype of x is float32
out8 = paddle.randint_like(x, low=-5, high=5, dtype="int32")
print(out8)
print(out8.dtype)
# [[0, -1]]  # random

# example 9:
# dtype is int64 and the dtype of x is float32
out9 = paddle.randint_like(x, low=-5, high=5, dtype="int64")
print(out9)
print(out9.dtype)
# [[0, -1]]  # random