o ) i'$@sddlmZddlZddlmZddlmZmZgdZGdddej j Z Gdd d ej j Z Gd d d ej j ZGd d d ej j ZdS)) annotationsN)Conv) get_act_layerget_norm_layer)FactorizedIncreaseBlockFactorizedReduceBlockP3DActiConvNormBlockActiConvNormBlockcs2eZdZdZdddddiffdfdd ZZS)rzV Up-sampling the features by two using linear interpolation and convolutions. RELUINSTANCEaffineT in_channelint out_channel spatial_dimsact_name tuple | str norm_namec st||_||_||_|jdvrtdttj|jf}|jdkr&dnd}|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__c/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/networks/blocks/dints_block.pyr0s4   z FactorizedIncreaseBlock.__init__ rrrrrrrrrr__name__ __module__ __qualname____doc__r0 __classcell__r>r>r<r?rs  rcs<eZdZdZdddddiffdfdd ZdddZZS)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 Trrrrrrrc st||_||_||_|jdvrtdttj|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. rrrrr"rFr#r-N)r/r0r1r2r3r4rr5ractconv_1conv_2rr,)r:rrrrrr;r<r>r?r0Ns:     zFactorizedReduceBlock.__init__x torch.Tensorreturnc Cs||}|jdkr+tj||||ddddddddddfgdd}ntj||||ddddddddfgdd}||}|S)zR The length along each spatial dimension must be a multiple of 2. r Nr")dim)rGr3r7catrHrIr,)r:rJoutr>r>r?forward~s  B: zFactorizedReduceBlock.forwardr@)rJrKrLrK)rBrCrDrEr0rPrFr>r>r<r?rHs  0rcs2eZdZdZdddddiffdfdd ZZS)rz) -- (act) -- (conv) -- (norm) -- rr r r Trrrr&r(rrrrc sHt||_||_t||_ttjdf}|jdkr1||df} dd|f} ||df} dd|f} n8|jdkrK|d|f} d|df} |d|f} d|df} n|jdkred||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.rrr!Fr#rHr,r-N) r/r0r1r2rZ_p3dmoderr5r4r6rr) r:rrr&r(rrrr;Z kernel_size0Z kernel_size1Zpadding0Zpadding1r<r>r?r0sb                   zP3DActiConvNormBlock.__init__)rrrrr&rr(rrrrrrrrAr>r>r<r?rs   rcs6eZdZdZdddddddiffdfdd ZZS)r z* -- (Acti) -- (Conv) -- (Norm) -- r r"r r r Trrrr&r(rrrrc 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. rrr!r"Fr#r,r-N) r/r0r1r2r3rr5r6rr) r:rrr&r(rrrr;r<r>r?r0s,  zActiConvNormBlock.__init__)rrrrr&rr(rrrrrrrrAr>r>r<r?r s r ) __future__rr7monai.networks.layers.factoriesrmonai.networks.layers.utilsrr__all__r8 SequentialrModulerrr r>r>r>r?s  2CU