o
    þÏ¯i@  ã                   @   s>   d dl Z d dlmZ G dd„ dejƒZG dd„ de jjƒZdS )é    Nc                   @   s   e Zd ZdZdd„ ZdS )ÚSwishz4
    Wrapper for the Swish activation function.
    c                 C   s
   t  |¡S ©N)ÚSwishFunctionÚapply)ÚselfÚx© r   úM/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/layers/swish.pyÚforward   s   
zSwish.forwardN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r	   r      s    r   c                   @   s(   e Zd ZdZedd„ ƒZedd„ ƒZdS )r   z²
    Implementation of the Swish activation function: x * sigmoid(x).

    Searching for activation functions. Ramachandran, Prajit and Zoph, Barret
    and Le, Quoc V. 2017
    c                 C   s   |t  |¡ }|  |¡ |S r   )ÚtorchÚsigmoidÚsave_for_backward)Úctxr   Úresultr   r   r	   r
      s   
zSwishFunction.forwardc                 C   s,   | j d }t |¡}||d|d|     S )Nr   é   )Úsaved_variablesr   r   )r   Úgrad_outputr   Ú	sigmoid_xr   r   r	   Úbackward   s   

zSwishFunction.backwardN)r   r   r   r   Ústaticmethodr
   r   r   r   r   r	   r      s    
r   )r   Útorch.nnÚnnÚModuler   ÚautogradÚFunctionr   r   r   r   r	   Ú<module>   s   	