random_
- paddle.Tensor. random_ ( x: Tensor, from_: int = 0, to: int | None = None, *, generator: None = None ) Tensor
-
Fills self tensor with numbers sampled from the discrete uniform distribution over [from, to - 1]. If not specified, the values are usually only bounded by self tensor’s data type. However, for floating point types, if unspecified, range will be [0, 2^mantissa] to ensure that every value is representable.
- Parameters
-
from (int, optional) – The lower bound on the range of random values to generate. Default is 0.
to (int|None, optional) – The upper bound on the range of random values to generate. Default is None.
generator (None) – Placeholder for random number generator (currently not implemented, reserved for future use).
- Returns
-
Tensor, A Tensor filled with random integers from a discrete uniform distribution in the range [
from,to).
Examples
>>> import paddle >>> x = paddle.zeros([3], dtype=paddle.int32) >>> x.random_(0, 10)
