U Ph'$@sddlmZddlZddlmZddlmZmZddddgZGd ddej j Z Gd ddej j Z Gd ddej j ZGd ddej j ZdS) ) annotationsN)Conv) get_act_layerget_norm_layerFactorizedIncreaseBlockFactorizedReduceBlockP3DActiConvNormBlockActiConvNormBlockcs>eZdZdZdddddiffdddddd fd d ZZS) rzV Up-sampling the features by two using linear interpolation and convolutions. RELUINSTANCEaffineTint tuple | str in_channel out_channel spatial_dimsact_name norm_namec st||_||_||_|jdkr.tdttj|jf}|jdkrLdnd}|dt j j d|dd |d t |d |d ||j|jd d dd dd d|dt ||j|jddS)a. Args: in_channel: number of input channels out_channel: number of output channels spatial_dims: number of spatial dimensions act_name: activation layer type and arguments. norm_name: feature normalization type and arguments. r spatial_dims must be 2 or 3.r trilinearbilinearuprT) scale_factormode align_cornersactinameconvrF in_channels out_channels kernel_sizestridepaddinggroupsbiasdilationnormr!rchannelsN)super__init__ _in_channel _out_channel _spatial_dims ValueErrorrCONV add_moduletorchnnUpsamplerr)selfrrrrr conv_typer __class__V/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/networks/blocks/dints_block.pyr1s6   z FactorizedIncreaseBlock.__init____name__ __module__ __qualname____doc__r1 __classcell__r?r?r=r@rs  csNeZdZdZdddddiffdddddd fd d Zd d d ddZZS)rz{ Down-sampling the feature by 2 using stride. The length along each spatial dimension must be a multiple of 2. r r r r Trrrc st||_||_||_|jdkr.tdttj|jf}t|d|_ ||j|jdddddddd|_ ||j|j|jdddddddd|_ t ||j|jd |_ d S) a0 Args: in_channel: number of input channels out_channel: number of output channels. spatial_dims: number of spatial dimensions. act_name: activation layer type and arguments. norm_name: feature normalization type and arguments. rrr rr#rFr$r.N)r0r1r2r3r4r5rr6ractconv_1conv_2rr-)r;rrrrrr<r=r?r@r1Ns:     zFactorizedReduceBlock.__init__z torch.Tensor)xreturnc Cs||}|jdkrVtj||||ddddddddddfgdd}n:tj||||ddddddddfgdd}||}|S)zR The length along each spatial dimension must be a multiple of 2. r Nr#)dim)rGr4r8catrHrIr-)r;rJoutr?r?r@forward~s   B: zFactorizedReduceBlock.forward)rBrCrDrEr1rOrFr?r?r=r@rHs   0c sBeZdZdZdddddiffdddddddd fd d ZZS) rz) -- (act) -- (conv) -- (norm) -- rr r r Trr)rrr'r)rrrc sHt||_||_t||_ttjdf}|jdkrb||df} dd|f} ||df} dd|f} np|jdkr|d|f} d|df} |d|f} d|df} n<|jdkrd||f} |ddf} d||f} |ddf} ntd| dt |d| d||j|j| d| dd dd | d ||j|j| d| dd dd | d t |d|jd dS)a; Args: in_channel: number of input channels. out_channel: number of output channels. kernel_size: kernel size to be expanded to 3D. padding: padding size to be expanded to 3D. mode: mode for the anisotropic kernels: - 0: ``(k, k, 1)``, ``(1, 1, k)``, - 1: ``(k, 1, k)``, ``(1, k, 1)``, - 2: ``(1, k, k)``. ``(k, 1, 1)``. act_name: activation layer type and arguments. norm_name: feature normalization type and arguments. r rr#rz`mode` must be 0, 1, or 2.rr r"Fr$rHr-r.N) r0r1r2r3rZ_p3dmoderr6r5r7rr) r;rrr'r)rrrr<Z kernel_size0Z kernel_size1Zpadding0Zpadding1r=r?r@r1sb                   zP3DActiConvNormBlock.__init__rAr?r?r=r@rs   c sFeZdZdZdddddddiffdddddd d d fd d ZZS) r z* -- (Acti) -- (Conv) -- (Norm) -- r r#r r r Trr)rrr'r)rrrc st||_||_||_ttj|jf}|dt|d|d||j|j|d|dddd|dt ||j|jdd S) a Args: in_channel: number of input channels. out_channel: number of output channels. kernel_size: kernel size of the convolution. padding: padding size of the convolution. spatial_dims: number of spatial dimensions. act_name: activation layer type and arguments. norm_name: feature normalization type and arguments. rr r"r#Fr$r-r.N) r0r1r2r3r4rr6r7rr) r;rrr'r)rrrr<r=r?r@r1s.  zActiConvNormBlock.__init__rAr?r?r=r@r s ) __future__rr8monai.networks.layers.factoriesrmonai.networks.layers.utilsrr__all__r9 SequentialrModulerrr r?r?r?r@ s   2CU