o
    Qe
                     @   s$   d dl mZ g ZG dd deZdS )   )UniformInitializerc                       s"   e Zd ZdZd fdd	Z  ZS )Uniformav  The uniform distribution initializer.

    Args:
        low (float, optional): Lower boundary of the uniform distribution. The default value is :math:`-1.0`.
        high (float, optional): Upper boundary of the uniform distribution. The default value is :math:`1.0`.
        name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

    Returns:
        A parameter initialized by uniform distribution.

    Examples:
        .. code-block:: python

            import paddle

            data = paddle.ones(shape=[3, 1, 2], dtype='float32')
            weight_attr = paddle.framework.ParamAttr(
                name="linear_weight",
                initializer=paddle.nn.initializer.Uniform(low=-0.5, high=0.5))
            bias_attr = paddle.framework.ParamAttr(
                name="linear_bias",
                initializer=paddle.nn.initializer.Uniform(low=-0.5, high=0.5))
            linear = paddle.nn.Linear(2, 2, weight_attr=weight_attr, bias_attr=bias_attr)
            # linear.weight:  [[-0.46245047  0.05260676]
            #                  [ 0.38054508  0.29169726]]
            # linear.bias:  [-0.2734719   0.23939109]
            
            res = linear(data)
            # res:  [[[-0.3553773  0.5836951]]
            #        [[-0.3553773  0.5836951]]
            #        [[-0.3553773  0.5836951]]]
                ?Nc                    sP   |d usJ d|d usJ d||ksJ dt t| j||ddddd d S )Nzlow should not be Nonezhigh should not be Nonez%high should greater or equal than low    r   )lowhighseedZdiag_numZ	diag_stepZdiag_val)superr   __init__)selfr   r   name	__class__ MD:\Projects\ConvertPro\env\Lib\site-packages\paddle/nn/initializer/uniform.pyr   6   s   
zUniform.__init__)r   r   N)__name__
__module____qualname____doc__r   __classcell__r   r   r   r   r      s    !r   N)Zfluid.initializerr   __all__r   r   r   r   r   <module>   s   