normal_

paddle. normal_ ( x, mean=0.0, std=1.0, name=None ) [source]

This is the inplace version of api normal, which returns a Tensor filled with random values sampled from a normal distribution. The output Tensor will be inplaced with input x. Please refer to api_tensor_noraml.

Parameters
  • x (Tensor) – The input tensor to be filled with random values.

  • mean (float|Tensor, optional) – The mean of the output Tensor’s normal distribution. If mean is float, all elements of the output Tensor shared the same mean. If mean is a Tensor(data type supports float32, float64), it has per-element means. Default is 0.0

  • std (float|Tensor, optional) – The standard deviation of the output Tensor’s normal distribution. If std is float, all elements of the output Tensor shared the same standard deviation. If std is a Tensor(data type supports float32, float64), it has per-element standard deviations. Defaule is 1.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

A Tensor filled with random values sampled from a normal distribution with mean and std .

Examples

>>> import paddle
>>> x = paddle.randn([3, 4])
>>> x.normal_()
>>> 
>>> print(x)
Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[ 0.06132207,  1.11349595,  0.41906244, -0.24858207],
 [-1.85169315, -1.50370061,  1.73954511,  0.13331604],
 [ 1.66359663, -0.55764782, -0.59911072, -0.57773495]])