Returns a Tensor filled with random values sampled from a Gaussian distribution, with ``shape`` and ``dtype``. Args: shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` . If ``shape`` is a list or tuple, each element
(
shape: ShapeLike,
mean: complex = 0.0,
std: float = 1.0,
seed: int = 0,
dtype: DTypeLike | None = None,
name: str | None = None,
*,
out: paddle.Tensor | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
)
| 626 | |
| 627 | |
| 628 | def gaussian( |
| 629 | shape: ShapeLike, |
| 630 | mean: complex = 0.0, |
| 631 | std: float = 1.0, |
| 632 | seed: int = 0, |
| 633 | dtype: DTypeLike | None = None, |
| 634 | name: str | None = None, |
| 635 | *, |
| 636 | out: paddle.Tensor | None = None, |
| 637 | device: PlaceLike | None = None, |
| 638 | requires_grad: bool = False, |
| 639 | ) -> Tensor: |
| 640 | """ |
| 641 | Returns a Tensor filled with random values sampled from a Gaussian |
| 642 | distribution, with ``shape`` and ``dtype``. |
| 643 | |
| 644 | Args: |
| 645 | shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` . |
| 646 | If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape []. |
| 647 | If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. |
| 648 | mean (float|int|complex, optional): Mean of the output tensor, default is 0.0. |
| 649 | std (float|int, optional): Standard deviation of the output tensor, default |
| 650 | is 1.0. |
| 651 | seed (int, optional): Random seed of generator. |
| 652 | dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the output Tensor. |
| 653 | Supported data types: bfloat16, float16, float32, float64, complex64, complex128. |
| 654 | Default is None, use global default dtype (see ``get_default_dtype`` |
| 655 | for details). |
| 656 | name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. |
| 657 | out(Tensor, optional): The output tensor. |
| 658 | device(PlaceLike|None, optional): The desired device of returned tensor. |
| 659 | if None, uses the current device for the default tensor type (see paddle.device.set_device()). |
| 660 | device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None. |
| 661 | requires_grad(bool, optional): If autograd should record operations on the returned tensor. Default: False. |
| 662 | |
| 663 | Returns: |
| 664 | Tensor, A Tensor filled with random values sampled from a Gaussian |
| 665 | distribution, with ``shape`` and ``dtype``. |
| 666 | """ |
| 667 | op_type_for_check = 'gaussian/standard_normal/randn/normal' |
| 668 | supported_dtypes = [ |
| 669 | 'float32', |
| 670 | 'float64', |
| 671 | 'float16', |
| 672 | 'uint16', |
| 673 | 'bfloat16', |
| 674 | 'complex64', |
| 675 | 'complex128', |
| 676 | ] |
| 677 | |
| 678 | if dtype is None: |
| 679 | dtype = paddle.framework.get_default_dtype() |
| 680 | if dtype not in supported_dtypes: |
| 681 | raise TypeError( |
| 682 | f"{op_type_for_check} only supports {supported_dtypes}, but the default dtype is {dtype}" |
| 683 | ) |
| 684 | if not isinstance(dtype, (core.VarDesc.VarType, core.DataType)): |
| 685 | dtype = convert_np_dtype_to_dtype_(dtype) |
no test coverage detected