o
    MeM  ã                   @   sT   d dl mZ g ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZd
S )é    )Úprint_functionc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú	EntryAttraÚ  
    Entry Config for paddle.static.nn.sparse_embedding with Parameter Server.

    Examples:
        .. code-block:: python

            import paddle

            sparse_feature_dim = 1024
            embedding_size = 64

            entry = paddle.distributed.ProbabilityEntry(0.1)

            input = paddle.static.data(name='ins', shape=[1], dtype='int64')

            emb = paddle.static.nn.sparse_embedding((
                input=input,
                size=[sparse_feature_dim, embedding_size],
                is_test=False,
                entry=entry,
                param_attr=paddle.ParamAttr(name="SparseFeatFactors",
                                           initializer=paddle.nn.initializer.Uniform()))

    c                 C   s
   d | _ d S )N)Ú_name©Úself© r   úMD:\Projects\ConvertPro\env\Lib\site-packages\paddle/distributed/entry_attr.pyÚ__init__.   s   
zEntryAttr.__init__c                 C   s   t dƒ‚)z–
        Returns the attributes of this parameter.

        Returns:
            Parameter attributes(map): The attributes of this parameter.
        zEntryAttr is base class)ÚNotImplementedErrorr   r   r   r   Ú_to_attr1   s   zEntryAttr._to_attrN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r      s    r   c                       ó(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )ÚProbabilityEntryaŒ  
    Examples:
        .. code-block:: python

            import paddle

            sparse_feature_dim = 1024
            embedding_size = 64

            entry = paddle.distributed.ProbabilityEntry(0.1)

            input = paddle.static.data(name='ins', shape=[1], dtype='int64')

            emb = paddle.static.nn.sparse_embedding((
                input=input,
                size=[sparse_feature_dim, embedding_size],
                is_test=False,
                entry=entry,
                param_attr=paddle.ParamAttr(name="SparseFeatFactors",
                                           initializer=paddle.nn.initializer.Uniform()))


    c                    sH   t t| ƒ ¡  t|tƒstdƒ‚|dks|dkrtdƒ‚d| _|| _d S )Nz$probability must be a float in (0,1)r   é   Zprobability_entry)Úsuperr   r	   Ú
isinstanceÚfloatÚ
ValueErrorr   Ú_probability)r   Zprobability©Ú	__class__r   r   r	   T   s   

zProbabilityEntry.__init__c                 C   ó   d  | jt| jƒg¡S ©Nú:)Újoinr   Ústrr   r   r   r   r   r   `   ó   zProbabilityEntry._to_attr©r   r   r   r   r	   r   Ú__classcell__r   r   r   r   r   ;   s    r   c                       r   )ÚCountFilterEntryaŠ  
    Examples:
        .. code-block:: python

            import paddle

            sparse_feature_dim = 1024
            embedding_size = 64

            entry = paddle.distributed.CountFilterEntry(10)

            input = paddle.static.data(name='ins', shape=[1], dtype='int64')

            emb = paddle.static.nn.sparse_embedding((
                input=input,
                size=[sparse_feature_dim, embedding_size],
                is_test=False,
                entry=entry,
                param_attr=paddle.ParamAttr(name="SparseFeatFactors",
                                           initializer=paddle.nn.initializer.Uniform()))

    c                    s@   t t| ƒ ¡  t|tƒstdƒ‚|dk rtdƒ‚d| _|| _d S )Nz3count_filter must be a valid integer greater than 0r   z<count_filter must be a valid integer greater or equal than 0Zcount_filter_entry)r   r"   r	   r   Úintr   r   Ú_count_filter)r   Zcount_filterr   r   r   r	   |   s   
ÿÿ
zCountFilterEntry.__init__c                 C   r   r   )r   r   r   r$   r   r   r   r   r   Š   r   zCountFilterEntry._to_attrr    r   r   r   r   r"   d   s    r"   c                       r   )ÚShowClickEntryaV  
    Examples:
        .. code-block:: python

            import paddle
            paddle.enable_static()

            sparse_feature_dim = 1024
            embedding_size = 64

            shows = paddle.static.data(name='show', shape=[1], dtype='int64')
            clicks = paddle.static.data(name='click', shape=[1], dtype='int64')
            input = paddle.static.data(name='ins', shape=[1], dtype='int64')

            entry = paddle.distributed.ShowClickEntry("show", "click")

            emb = paddle.static.nn.sparse_embedding(
                input=input,
                size=[sparse_feature_dim, embedding_size],
                is_test=False,
                entry=entry,
                param_attr=paddle.ParamAttr(name="SparseFeatFactors",
                                           initializer=paddle.nn.initializer.Uniform()))


    c                    s@   t t| ƒ ¡  t|tƒrt|tƒstdƒ‚d| _|| _|| _d S )Nz"show_name click_name must be a strZshow_click_entry)	r   r%   r	   r   r   r   r   Ú
_show_nameÚ_click_name)r   Z	show_nameZ
click_namer   r   r   r	   ª   s   
zShowClickEntry.__init__c                 C   s   d  | j| j| jg¡S r   )r   r   r&   r'   r   r   r   r   r   ´   r   zShowClickEntry._to_attrr    r   r   r   r   r%   Ž   s    
r%   N)Ú
__future__r   Ú__all__Úobjectr   r   r"   r%   r   r   r   r   Ú<module>   s   ')*