MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/networks/nets/basic_unet.py:94–150  ·  view source on GitHub ↗

Args: spatial_dims: number of spatial dimensions. in_chns: number of input channels to be upsampled. cat_chns: number of channels from the encoder. out_chns: number of output channels. act: activation type and arguments.

(
        self,
        spatial_dims: int,
        in_chns: int,
        cat_chns: int,
        out_chns: int,
        act: str | tuple,
        norm: str | tuple,
        bias: bool,
        dropout: float | tuple = 0.0,
        upsample: str = "deconv",
        pre_conv: nn.Module | str | None = "default",
        interp_mode: str = "linear",
        align_corners: bool | None = True,
        halves: bool = True,
        is_pad: bool = True,
    )

Source from the content-addressed store, hash-verified

92 """upsampling, concatenation with the encoder feature map, two convolutions"""
93
94 def __init__(
95 self,
96 spatial_dims: int,
97 in_chns: int,
98 cat_chns: int,
99 out_chns: int,
100 act: str | tuple,
101 norm: str | tuple,
102 bias: bool,
103 dropout: float | tuple = 0.0,
104 upsample: str = "deconv",
105 pre_conv: nn.Module | str | None = "default",
106 interp_mode: str = "linear",
107 align_corners: bool | None = True,
108 halves: bool = True,
109 is_pad: bool = True,
110 ):
111 """
112 Args:
113 spatial_dims: number of spatial dimensions.
114 in_chns: number of input channels to be upsampled.
115 cat_chns: number of channels from the encoder.
116 out_chns: number of output channels.
117 act: activation type and arguments.
118 norm: feature normalization type and arguments.
119 bias: whether to have a bias term in convolution blocks.
120 dropout: dropout ratio. Defaults to no dropout.
121 upsample: upsampling mode, available options are
122 ``"deconv"``, ``"pixelshuffle"``, ``"nontrainable"``.
123 pre_conv: a conv block applied before upsampling.
124 Only used in the "nontrainable" or "pixelshuffle" mode.
125 interp_mode: {``"nearest"``, ``"linear"``, ``"bilinear"``, ``"bicubic"``, ``"trilinear"``}
126 Only used in the "nontrainable" mode.
127 align_corners: set the align_corners parameter for upsample. Defaults to True.
128 Only used in the "nontrainable" mode.
129 halves: whether to halve the number of channels during upsampling.
130 This parameter does not work on ``nontrainable`` mode if ``pre_conv`` is `None`.
131 is_pad: whether to pad upsampling features to fit features from encoder. Defaults to True.
132
133 """
134 super().__init__()
135 if upsample == "nontrainable" and pre_conv is None:
136 up_chns = in_chns
137 else:
138 up_chns = in_chns // 2 if halves else in_chns
139 self.upsample = UpSample(
140 spatial_dims,
141 in_chns,
142 up_chns,
143 2,
144 mode=upsample,
145 pre_conv=pre_conv,
146 interp_mode=interp_mode,
147 align_corners=align_corners,
148 )
149 self.convs = TwoConv(spatial_dims, cat_chns + up_chns, out_chns, act, norm, bias, dropout)
150 self.is_pad = is_pad
151

Callers

nothing calls this directly

Calls 3

UpSampleClass · 0.90
TwoConvClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected