U Ph@sfddlmZddlmZddlZddlmZddlmZddl m Z ddl m Z Gdddej ZdS) ) annotations)SequenceN) Convolution same_padding)Convc sHeZdZdZddddddd d d d d fd d ZdddddZZS) SimpleASPPa A simplified version of the atrous spatial pyramid pooling (ASPP) module. Chen et al., Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation. https://arxiv.org/abs/1802.02611 Wang et al., A Noise-robust Framework for Automatic Segmentation of COVID-19 Pneumonia Lesions from CT Images. https://ieeexplore.ieee.org/document/9109297 r r r BATCH LEAKYRELUFintz Sequence[int]ztuple | str | NoneboolNone) spatial_dims in_channelsconv_out_channels kernel_sizes dilations norm_type acti_typebiasreturnc  stt|t|kr8tdt|dt|dtddt||D} t|_t||| D]2\} } } t t j |f||| | | d} |j | qf|t| }t |||d|||d|_ d S) a Args: spatial_dims: number of spatial dimensions, could be 1, 2, or 3. in_channels: number of input channels. conv_out_channels: number of output channels of each atrous conv. The final number of output channels is conv_out_channels * len(kernel_sizes). kernel_sizes: a sequence of four convolutional kernel sizes. Defaults to (1, 3, 3, 3) for four (dilated) convolutions. dilations: a sequence of four convolutional dilation parameters. Defaults to (1, 2, 4, 6) for four (dilated) convolutions. norm_type: final kernel-size-one convolution normalization type. Defaults to batch norm. acti_type: final kernel-size-one convolution activation type. Defaults to leaky ReLU. bias: whether to have a bias term in convolution blocks. Defaults to False. According to `Performance Tuning Guide `_, if a conv layer is directly followed by a batch norm layer, bias should be False. Raises: ValueError: When ``kernel_sizes`` length differs from ``dilations``. See also: :py:class:`monai.networks.layers.Act` :py:class:`monai.networks.layers.Conv` :py:class:`monai.networks.layers.Norm` z?kernel_sizes and dilations length must match, got kernel_sizes=z dilations=.css|]\}}t||VqdS)Nr).0kdr"O/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/networks/blocks/aspp.py Psz&SimpleASPP.__init__..)r out_channels kernel_sizedilationpaddingr )rrr%r&actnormrN)super__init__len ValueErrortuplezipnn ModuleListconvsrCONVappendrconv_k1)selfrrrrrrrrZpadsr r!pZ_convr% __class__r"r#r,#s4'    zSimpleASPP.__init__z torch.Tensor)xrcs,tjfdd|jDdd}||}|S)z^ Args: x: in shape (batch, channel, spatial_1[, spatial_2, ...]). csg|] }|qSr"r")rconvr;r"r# isz&SimpleASPP.forward..r )dim)torchcatr3r6)r7r;x_outr"r=r#forwardds zSimpleASPP.forward)r r rrF)__name__ __module__ __qualname____doc__r,rC __classcell__r"r"r9r#rs$Ar) __future__rcollections.abcrr@torch.nnr1Z"monai.networks.blocks.convolutionsrmonai.networks.layersrmonai.networks.layers.factoriesrModulerr"r"r"r# s