o
    #j                     @   s0   d dl mZ ddlmZ g ZG dd deZdS )   )
functional   )Layerc                       s2   e Zd ZdZd fdd	Zdd	 Zd
d Z  ZS )PairwiseDistancea  

    It computes the pairwise distance between two vectors. The
    distance is calculated by p-oreder norm:

    .. math::

        \Vert x \Vert _p = \left( \sum_{i=1}^n \vert x_i \vert ^ p \right) ^ {1/p}.

    Parameters:
        p (float, optional): The order of norm. Default: :math:`2.0`.
        epsilon (float, optional): Add small value to avoid division by zero.
            Default: :math:`1e-6`.
        keepdim (bool, optional): Whether to reserve the reduced dimension
            in the output Tensor. The result tensor is one dimension less than
            the result of ``|x-y|`` unless :attr:`keepdim` is True. Default: False.
        name (str, optional): For details, please refer to :ref:`api_guide_Name`.
            Generally, no setting is required. Default: None.

    Shape:
        - x: :math:`[N, D]` or :math:`[D]`, where :math:`N` is batch size, :math:`D`
          is the dimension of the data. Available data type is float16, float32, float64.
        - y: :math:`[N, D]` or :math:`[D]`, y have the same dtype as x.
        - output: The same dtype as input tensor.
            - If :attr:`keepdim` is True, the output shape is :math:`[N, 1]` or :math:`[1]`,
              depending on whether the input has data shaped as :math:`[N, D]`.
            - If :attr:`keepdim` is False, the output shape is :math:`[N]` or :math:`[]`,
              depending on whether the input has data shaped as :math:`[N, D]`.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> x = paddle.to_tensor([[1., 3.], [3., 5.]], dtype=paddle.float64)
            >>> y = paddle.to_tensor([[5., 6.], [7., 8.]], dtype=paddle.float64)
            >>> dist = paddle.nn.PairwiseDistance()
            >>> distance = dist(x, y)
            >>> print(distance)
            Tensor(shape=[2], dtype=float64, place=Place(cpu), stop_gradient=True,
            [4.99999860, 4.99999860])
           @ư>FNc                    s&   t    || _|| _|| _|| _d S N)super__init__pepsilonkeepdimname)selfr   r   r   r   	__class__ Y/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/nn/layer/distance.pyr
   @   s
   

zPairwiseDistance.__init__c                 C   s   t ||| j| j| j| jS r   )FZpairwise_distancer   r   r   r   )r   xyr   r   r   forwardG   s   zPairwiseDistance.forwardc                 C   sL   d}| j dkr|d7 }| jdur|d7 }| jd ur|d7 }|jdi | jS )Nzp={p}r   z, epsilon={epsilon}Fz, keepdim={keepdim}z, name={name}r   )r   r   r   format__dict__)r   Zmain_strr   r   r   
extra_reprL   s   


zPairwiseDistance.extra_repr)r   r   FN)__name__
__module____qualname____doc__r
   r   r   __classcell__r   r   r   r   r      s
    *r   N) r   r   Zlayersr   __all__r   r   r   r   r   <module>   s   