o
    _{j’	  ã                   @   sL   d dl mZ d dlmZ ddlmZ ddlmZ e ¡ G dd„ deƒƒZ	dS )	é    N)Únormal_inité   )ÚHEADSé   )ÚBaseHeadc                       s@   e Zd ZdZedd�dddf‡ fdd„	Zd	d
„ Zdd„ Z‡  ZS )ÚI3DHeadaS  Classification head for I3D.

    Args:
        num_classes (int): Number of classes to be classified.
        in_channels (int): Number of channels in input feature.
        loss_cls (dict): Config for building loss.
            Default: dict(type='CrossEntropyLoss')
        spatial_type (str): Pooling type in spatial dimension. Default: 'avg'.
        dropout_ratio (float): Probability of dropout layer. Default: 0.5.
        init_std (float): Std value for Initiation. Default: 0.01.
        kwargs (dict, optional): Any keyword argument to be used to initialize
            the head.
    ÚCrossEntropyLoss)ÚtypeÚavgg      à?g{®Gáz„?c                    s‚   t ƒ j|||fi |¤Ž || _|| _|| _| jdkr#tj| jd�| _nd | _t | j	| j
¡| _| jdkr<t d¡| _d S d | _d S )Nr   )Úpr
   )r   r   r   )ÚsuperÚ__init__Úspatial_typeÚdropout_ratioÚinit_stdÚnnÚDropoutÚdropoutÚLinearÚin_channelsÚnum_classesÚfc_clsÚAdaptiveAvgPool3dÚavg_pool)Úselfr   r   Úloss_clsr   r   r   Úkwargs©Ú	__class__© ú4/root/disk_3tb/HAC/mmaction/models/heads/i3d_head.pyr      s   


zI3DHead.__init__c                 C   s   t | j| jd� dS )z%Initiate the parameters from scratch.)ÚstdN)r   r   r   )r   r   r   r    Úinit_weights1   s   zI3DHead.init_weightsc                 C   sL   | j dur
|   |¡}| jdur|  |¡}| |jd d¡}|  |¡}||fS )zÏDefines the computation performed at every call.

        Args:
            x (torch.Tensor): The input data.

        Returns:
            torch.Tensor: The classification scores for input samples.
        Nr   éÿÿÿÿ)r   r   ÚviewÚshaper   )r   ÚxÚ	cls_scorer   r   r    Úforward5   s   





zI3DHead.forward)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údictr   r"   r(   Ú__classcell__r   r   r   r    r      s    úr   )
Útorch.nnr   Úmmcv.cnnr   Úregistryr   Úbaser   Úregister_moduler   r   r   r   r    Ú<module>   s    