o ) i@szddlmZddlmZddlZddlmZddlmZm Z ddl m Z m Z ddgZ GdddejZGd ddeZdS) ) annotations)SequenceN) Convolution ResidualUnit)ActNorm DenseBlockConvDenseBlockcs*eZdZdZdfdd 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 layersSequence[nn.Module]cs2tt|D] \}}|d||q dS)Nr )super__init__ enumerate add_module)selfr il __class__b/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/networks/blocks/denseblock.pyr "s zDenseBlock.__init__cCs*|D]}||}t||gd}q|S)N)childrentorchcat)rxrresultrrrforward's zDenseBlock.forward)r r )__name__ __module__ __qualname____doc__r r __classcell__rrrrrscs@eZdZdZddddejejddfdfdd 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. NrNDAT spatial_dimsint in_channelschannels Sequence[int] dilationsSequence[int] | None kernel_sizeSequence[int] | int num_res_units adn_orderingstracttuple | str | Nonenormdropouttuple | str | float | Nonebiasboolc s||_||_||_||_||_| |_| |_| |_|} |dur |ndgt|}g} t|t|kr5t dt ||D]\}}| | ||}| || |7} q:t | dS)Nrz/Length of `channels` and `dilations` must match)r%r,r.r/r1r3r4r6len ValueErrorzip _get_layerappendr r )rr%r'r(r*r,r.r/r1r3r4r6Z l_channelsr cdlayerrrrr Bs$  zConvDenseBlock.__init__cCsb|jdkrt|j||d|j|j|j|j|j|j||jd St |j||d|j|j|j|j||jd S)Nrr) r%r' out_channelsstridesr,subunitsr/r1r3r4dilationr6) r%r'r@rAr,r1r3r4rCr6) r.rr%r,r/r1r3r4r6r)rr'r@rCrrrr;gs6 zConvDenseBlock._get_layer)r%r&r'r&r(r)r*r+r,r-r.r&r/r0r1r2r3r2r4r5r6r7) rrr r!rPRELUrINSTANCEr r;r"rrrrr /s%) __future__rtypingrrtorch.nnnnZmonai.networks.blocksrrmonai.networks.layers.factoriesrrZ__ALL__ Sequentialrr rrrrs