normal¶
- paddle. normal ( mean=0.0, std=1.0, shape=None, name=None ) [source]
-
This OP returns a Tensor filled with random values sampled from a normal distribution with
meanandstd(standard deviation) .If
meanis a Tensor, the output Tensor has the same shape and data type asmean. Ifmeanis not a Tensor andstdis a Tensor, the output Tensor has the same shape and data type asstd. Ifmeanandstdare not a Tensor, the output Tensor has the same shape asshape, with data type float32.If
meanandstdare Tensor, the num of elements ofmeanandstdshould be the same.- Parameters
-
mean (float|Tensor, optional) – The mean of the output Tensor’s normal distribution. If
meanis float, all elements of the output Tensor shared the same mean. Ifmeanis a Tensor(data type supports float32, float64), it has per-element means. Default is 0.0std (float|Tensor, optional) – The standard deviation of the output Tensor’s normal distribution. If
stdis float, all elements of the output Tensor shared the same standard deviation. Ifstdis a Tensor(data type supports float32, float64), it has per-element standard deviations. Defaule is 1.0shape (list|tuple|Tensor, optional) – The shape of the output Tensor. If
shapeis a list or tuple, the elements of it should be integers or Tensors (with the shape [1], and the data type int32 or int64). Ifshapeis a Tensor, it should be a 1-D Tensor(with the data type int32 or int64). Ifmeanorstdis a Tensor, the shape of the output Tensor is the same asmeanorstd, attrshapeis ignored. Default is Nonename (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
A Tensor filled with random values sampled from a normal distribution with
meanandstd.
Examples
import paddle out1 = paddle.normal(shape=[2, 3]) # [[ 0.17501129 0.32364586 1.561118 ] # random # [-1.7232178 1.1545963 -0.76156676]] # random mean_tensor = paddle.to_tensor([1.0, 2.0, 3.0]) out2 = paddle.normal(mean=mean_tensor) # [ 0.18644847 -1.19434458 3.93694787] # random std_tensor = paddle.to_tensor([1.0, 2.0, 3.0]) out3 = paddle.normal(mean=mean_tensor, std=std_tensor) # [1.00780561 3.78457445 5.81058198] # random
