Ë
    Fêñi«  ã                   óF   — d Z ddlZddlmZ  G d„ dej                  «      Zy)zActivation modules.é    Nc                   ó^   ‡ — e Zd ZdZddˆ fd„Zdej                  dej                  fd„Zˆ xZS )ÚAGLUaF  Unified activation function module from AGLU.

    This class implements a parameterized activation function with learnable parameters lambda and kappa, based on the
    AGLU (Adaptive Gated Linear Unit) approach.

    Attributes:
        act (nn.Softplus): Softplus activation function with negative beta.
        lambd (nn.Parameter): Learnable lambda parameter initialized with uniform distribution.
        kappa (nn.Parameter): Learnable kappa parameter initialized with uniform distribution.

    Methods:
        forward: Compute the forward pass of the Unified activation function.

    Examples:
        >>> import torch
        >>> m = AGLU()
        >>> input = torch.randn(2)
        >>> output = m(input)
        >>> print(output.shape)
        torch.Size([2])

    References:
        https://github.com/kostas1515/AGLU
    Úreturnc           	      óŒ  •— t         ‰| �  «        t        j                  d¬«      | _        t        j
                  t        j                  j                  t        j                  d||¬«      «      «      | _
        t        j
                  t        j                  j                  t        j                  d||¬«      «      «      | _        y)zEInitialize the Unified activation function with learnable parameters.g      ð¿)Úbetaé   )ÚdeviceÚdtypeN)ÚsuperÚ__init__ÚnnÚSoftplusÚactÚ	ParameterÚinitÚuniform_ÚtorchÚemptyÚlambdÚkappa)Úselfr	   r
   Ú	__class__s      €úc/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/ultralytics/nn/modules/activation.pyr   zAGLU.__init__"   sx   ø€ ä‰ÑÔÜ—;‘; DÔ)ˆŒÜ—\‘\¤"§'¡'×"2Ñ"2´5·;±;¸qÈÐW\Ô3]Ó"^Ó_ˆŒ
Ü—\‘\¤"§'¡'×"2Ñ"2´5·;±;¸qÈÐW\Ô3]Ó"^Ó_ˆ�
ó    Úxc           	      óÞ   — t        j                  | j                  d¬«      }t        j                  d|z  | j	                  | j
                  |z  t        j                  |«      z
  «      z  «      S )a  Apply the Adaptive Gated Linear Unit (AGLU) activation function.

        This forward method implements the AGLU activation function with learnable parameters lambda and kappa. The
        function applies a transformation that adaptively combines linear and non-linear components.

        Args:
            x (torch.Tensor): Input tensor to apply the activation function to.

        Returns:
            (torch.Tensor): Output tensor after applying the AGLU activation function, with the same shape as the input.
        g-Cëâ6?)Úminr   )r   Úclampr   Úexpr   r   Úlog)r   r   Úlams      r   ÚforwardzAGLU.forward)   sN   € ô �k‰k˜$Ÿ*™*¨&Ô1ˆÜ�y‰y˜!˜c™' T§X¡X¨t¯z©z¸A©~ÄÇÁÈ3ÃÑ.OÓ%PÑPÓQÐQr   )NN)r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚTensorr"   Ú__classcell__)r   s   @r   r   r      s,   ø„ ñö2`ðR˜Ÿ™ð R¨%¯,©,÷ Rr   r   )r&   r   Útorch.nnr   ÚModuler   © r   r   ú<module>r,      s    ðá ã Ý ô.Rˆ2�9‰9õ .Rr   