uniform_¶
- paddle.Tensor. uniform_ ( x, min=- 1.0, max=1.0, seed=0, name=None )
-
This is the inplace version of OP
uniform
, which returns a Tensor filled with random values sampled from a uniform distribution. The output Tensor will be inplaced with inputx
. Please refer to uniform.- Parameters
-
x (Tensor) – The input tensor to be filled with random values.
min (float|int, optional) – The lower bound on the range of random values to generate,
min
is included in the range. Default is -1.0.max (float|int, optional) – The upper bound on the range of random values to generate,
max
is excluded in the range. Default is 1.0.seed (int, optional) – Random seed used for generating samples. If seed is 0, it will use the seed of the global default generator (which can be set by paddle.seed). Note that if seed is not 0, this operator will always generate the same random numbers every time. Default is 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.
- Returns
-
The input tensor x filled with random values sampled from a uniform distribution in the range [
min
,max
). - Return type
-
Tensor
Examples
>>> import paddle >>> # example: >>> x = paddle.ones(shape=[3, 4]) >>> x.uniform_() >>> Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True, [[-0.50484276, 0.49580324, 0.33357990, -0.93924278], [ 0.39779735, 0.87677515, -0.24377221, 0.06212139], [-0.92499518, -0.96244860, 0.79210341, -0.78228098]]) >>>