U
    Ph                     @  sB   d dl mZ d dlmZ d dlmZmZmZ G dd dejZ	dS )    )annotationsN)get_act_layerget_dropout_layerget_norm_layerc                
      s6   e Zd ZdZddddddddd	d
 fddZ  ZS )ADNa  
    Constructs a sequential module of optional activation (A), dropout (D), and normalization (N) layers
    with an arbitrary order::

        -- (Norm) -- (Dropout) -- (Acti) --

    Args:
        ordering: a string representing the ordering of activation, dropout, and normalization. Defaults to "NDA".
        in_channels: `C` from an expected input of size (N, C, H[, W, D]).
        act: activation type and arguments. Defaults to PReLU.
        norm: feature normalization type and arguments. Defaults to instance norm.
        norm_dim: determine the spatial dimensions of the normalization layer.
            defaults to `dropout_dim` if unspecified.
        dropout: dropout ratio. Defaults to no dropout.
        dropout_dim: determine the spatial dimensions of dropout.
            defaults to `norm_dim` if unspecified.

            - When dropout_dim = 1, randomly zeroes some of the elements for each channel.
            - When dropout_dim = 2, Randomly zeroes out entire channels (a channel is a 2D feature map).
            - When dropout_dim = 3, Randomly zeroes out entire channels (a channel is a 3D feature map).

    Examples::

        # activation, group norm, dropout
        >>> norm_params = ("GROUP", {"num_groups": 1, "affine": False})
        >>> ADN(norm=norm_params, in_channels=1, dropout_dim=1, dropout=0.8, ordering="AND")
        ADN(
            (A): ReLU()
            (N): GroupNorm(1, 1, eps=1e-05, affine=False)
            (D): Dropout(p=0.8, inplace=False)
        )

        # LeakyReLU, dropout
        >>> act_params = ("leakyrelu", {"negative_slope": 0.1, "inplace": True})
        >>> ADN(act=act_params, in_channels=1, dropout_dim=1, dropout=0.8, ordering="AD")
        ADN(
            (A): LeakyReLU(negative_slope=0.1, inplace=True)
            (D): Dropout(p=0.8, inplace=False)
        )

    See also:

        :py:class:`monai.networks.layers.Dropout`
        :py:class:`monai.networks.layers.Act`
        :py:class:`monai.networks.layers.Norm`
        :py:class:`monai.networks.layers.split_args`

    NDANRELUstrz
int | Noneztuple | str | Noneztuple | str | float | NoneNone)orderingin_channelsactnormnorm_dimdropoutdropout_dimreturnc           
        s   t    d d d d}|d k	rL|d kr6|d kr6tdt||p@||d|d< |d k	r`t||d< |d k	r|d kr|d krtdt||p|d|d< | D ]>}	|	|krtd| d	|	 d
||	 d k	r| |	||	  qd S )N)ADNz.norm_dim or dropout_dim needs to be specified.)namespatial_dimschannelsr   r   )r   r   r   zordering must be a string of z, got z in it.)super__init__
ValueErrorr   r   r   upper
add_module)
selfr   r   r   r   r   r   r   op_dictitem	__class__ T/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/networks/blocks/acti_norm.pyr   E   s"    

zADN.__init__)r   Nr   NNNN)__name__
__module____qualname____doc__r   __classcell__r#   r#   r!   r$   r      s   3       r   )

__future__r   torch.nnnnZmonai.networks.layers.utilsr   r   r   
Sequentialr   r#   r#   r#   r$   <module>   s   