U Ph@szddlmZddlmZddlZddlmZddlmZm Z ddl m Z m Z ddgZ GdddejZGd ddeZdS) ) annotations)SequenceN) Convolution ResidualUnit)ActNorm DenseBlockConvDenseBlockcs.eZdZdZddfdd ZddZZS)ra\ A DenseBlock is a sequence of layers where each layer's outputs are concatenated with their inputs. This has the effect of accumulating outputs from previous layers as inputs to later ones and as the final output of the block. Args: layers: sequence of nn.Module objects to define the individual layers of the dense block zSequence[nn.Module])layerscs2tt|D]\}}|d||qdS)Nr )super__init__ enumerate add_module)selfr il __class__U/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/networks/blocks/denseblock.pyr "s zDenseBlock.__init__cCs*|D]}||}t||gd}q|S)N)childrentorchcat)rxrresultrrrforward's zDenseBlock.forward)__name__ __module__ __qualname____doc__r r __classcell__rrrrrsc sXeZdZdZddddejejddfdddd d dd d d d dd fdd ZddZ Z S)r a This dense block is defined as a sequence of `Convolution` or `ResidualUnit` blocks. The `_get_layer` method returns an object for each layer and can be overridden to change the composition of the block. Args: spatial_dims: number of spatial dimensions. in_channels: number of input channels. channels: output channels for each layer. dilations: dilation value for each layer. kernel_size: convolution kernel size. Defaults to 3. num_res_units: number of convolutions. Defaults to 2. adn_ordering: a string representing the ordering of activation, normalization, and dropout. Defaults to "NDA". act: activation type and arguments. Defaults to PReLU. norm: feature normalization type and arguments. Defaults to instance norm. dropout: dropout ratio. Defaults to no dropout. bias: whether to have a bias term. Defaults to True. NrNDATintz Sequence[int]zSequence[int] | NonezSequence[int] | intstrztuple | str | Noneztuple | str | float | Nonebool) spatial_dims in_channelschannels dilations kernel_size num_res_units adn_orderingactnormdropoutbiasc s||_||_||_||_||_| |_| |_| |_|} |dk r@|n dgt|}g} t|t|krjt dt ||D](\}}| | ||}| || |7} qtt | dS)Nrz/Length of `channels` and `dilations` must match)r'r+r,r-r.r/r0r1len ValueErrorzip _get_layerappendr r )rr'r(r)r*r+r,r-r.r/r0r1Z l_channelsr cdlayerrrrr Bs$  zConvDenseBlock.__init__cCsf|jdkr:t|j||d|j|j|j|j|j|j||jd St |j||d|j|j|j|j||jd SdS)Nrr) r'r( out_channelsstridesr+subunitsr-r.r/r0dilationr1) r'r(r:r;r+r.r/r0r=r1) r,rr'r+r-r.r/r0r1r)rr(r:r=rrrr5gs6 zConvDenseBlock._get_layer) rrrr rPRELUrINSTANCEr r5r!rrrrr /s(%) __future__rtypingrrtorch.nnnnZmonai.networks.blocksrrmonai.networks.layers.factoriesrr__ALL__ Sequentialrr rrrr s