- 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 input
x. Please refer to api_tensor_uniform.
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,
minis included in the range. Default is -1.0.
max (float|int, optional) – The upper bound on the range of random values to generate,
maxis 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.
The input tensor x filled with random values sampled from a uniform distribution in the range [
- Return type
import paddle # example: x = paddle.ones(shape=[3, 4]) x.uniform_() print(x) # [[ 0.84524226, 0.6921872, 0.56528175, 0.71690357], # random # [-0.34646994, -0.45116323, -0.09902662, -0.11397249], # random # [ 0.433519, 0.39483607, -0.8660099, 0.83664286]] # random