log_normal¶
- paddle. log_normal ( mean: float | Tensor = 1.0, std: float | Tensor = 2.0, shape: ShapeLike | None = None, name: str | None = None ) Tensor [source]
-
Returns a Tensor filled with random values sampled from a Log Normal Distribution, with
mean
,std
. The Log Normal Distribution is defined as follows\[f(x) = \frac{1}{x\sigma\sqrt{2\pi}}e^{-\frac{(\ln{x}-\mu)^2}{2\sigma^2}}\]- Parameters
-
mean (float|Tensor, optional) – The mean of the output Tensor’s underlying normal distribution. If
mean
is float, all elements of the output Tensor share the same mean. Ifmean
is a Tensor(data type supports float32, float64), it has per-element means. Default is 1.0std (float|Tensor, optional) – The standard deviation of the output Tensor’s underlying normal distribution. If
std
is float, all elements of the output Tensor share the same standard deviation. Ifstd
is a Tensor(data type supports float32, float64), it has per-element standard deviations. Default is 2.0shape (tuple|list|Tensor|None, optional) – Shape of the Tensor to be created. The data type is
int32
orint64
. Ifshape
is a list or tuple, each element of it should be integer or 0-D Tensor with shape []. Ifshape
is an Tensor, it should be an 1-D Tensor which represents a list. Ifmean
orstd
is a Tensor, the shape of the output Tensor is the same asmean
orstd
, attrshape
is ignored. Default is Nonename (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
Tensor, A Tensor filled with random values sampled from a log normal distribution with the underlying normal distribution’s
mean
andstd
.
Examples
>>> import paddle >>> paddle.seed(200) >>> out1 = paddle.log_normal(shape=[2, 3]) >>> print(out1) Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True, [[4.01107359 , 3.53824377 , 25.79078865], [0.83332109 , 0.40513405 , 2.09763741 ]]) >>> mean_tensor = paddle.to_tensor([1.0, 2.0, 3.0]) >>> out2 = paddle.log_normal(mean=mean_tensor) >>> print(out2) Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True, [4.45330524 , 0.57903880 , 31.82369995]) >>> std_tensor = paddle.to_tensor([1.0, 2.0, 3.0]) >>> out3 = paddle.log_normal(mean=mean_tensor, std=std_tensor) >>> print(out3) Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True, [10.31321430, 8.97369766 , 35.76752090])