randint(low, high=None, shape=None, out=None, dtype=None, device=None, stop_gradient=False, seed=0, name=None)
This function returns a Tensor filled with random integers from the “discrete uniform” distribution of the specified data type in the interval [low, high). If high is None (the default), then results are from [0, low).
low (int) – The lower bound on the range of random values to generate, the low is included in the range. (unless high=None, in which case this parameter is one above the highest such integer).
high (int, optional) – The upper bound on the range of random values to generate, the high is excluded in the range. Default None(see above for behavior if high=None).
shape (list|tuple|Variable, optional) – The shape of the output Tensor, if the shape is a list or tuple, its elements can be an integer or a Tensor with the shape , and the type of the Tensor must be int32 or int64. If the shape is a Variable, it is a 1-D Tensor, and the type of the Tensor must be int32 or int64. Default is None, in which case the shape is .
out (Variable, optional) – Optional output which can be any created Variable that meets the requirements to store the result of operation. if out is None, a new Varibale will be create to store the result.
dtype (np.dtype|core.VarDesc.VarType|str, optional) – Data type of the output Tensor which can be int32, int64, if dytpe is None, the data type of created Tensor is int64
device (str, optional) – This parameter specifies that the Tensor is created on the GPU or CPU.
stop_gradient (bool, optional) – Indicating if we stop gradient from current(out) Variable, default value is False.
seed (int, optional) – Random seed used for permute samples. If seed is equal to 0, it means use a seed generated by the system. Note that if seed is not 0, this operator will always generate the same random permutation every time. Default: 0.
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.
A Tensor of the specified shape filled with random integers.
- Return type
TypeError– Randint’s low must less then high.