Args: in_planes: number of input channels. planes: number of output channels (taking expansion into account). spatial_dims: number of spatial dimensions of the input image. stride: stride to use for second conv layer. downsample: w
(
self,
in_planes: int,
planes: int,
spatial_dims: int = 3,
stride: int = 1,
downsample: nn.Module | partial | None = None,
act: str | tuple = ("relu", {"inplace": True}),
norm: str | tuple = "batch",
)
| 126 | expansion = 4 |
| 127 | |
| 128 | def __init__( |
| 129 | self, |
| 130 | in_planes: int, |
| 131 | planes: int, |
| 132 | spatial_dims: int = 3, |
| 133 | stride: int = 1, |
| 134 | downsample: nn.Module | partial | None = None, |
| 135 | act: str | tuple = ("relu", {"inplace": True}), |
| 136 | norm: str | tuple = "batch", |
| 137 | ) -> None: |
| 138 | """ |
| 139 | Args: |
| 140 | in_planes: number of input channels. |
| 141 | planes: number of output channels (taking expansion into account). |
| 142 | spatial_dims: number of spatial dimensions of the input image. |
| 143 | stride: stride to use for second conv layer. |
| 144 | downsample: which downsample layer to use. |
| 145 | act: activation type and arguments. Defaults to relu. |
| 146 | norm: feature normalization type and arguments. Defaults to batch norm. |
| 147 | """ |
| 148 | |
| 149 | super().__init__() |
| 150 | |
| 151 | conv_type: Callable = Conv[Conv.CONV, spatial_dims] |
| 152 | norm_layer = partial(get_norm_layer, name=norm, spatial_dims=spatial_dims) |
| 153 | |
| 154 | self.conv1 = conv_type(in_planes, planes, kernel_size=1, bias=False) |
| 155 | self.bn1 = norm_layer(channels=planes) |
| 156 | self.conv2 = conv_type(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False) |
| 157 | self.bn2 = norm_layer(channels=planes) |
| 158 | self.conv3 = conv_type(planes, planes * self.expansion, kernel_size=1, bias=False) |
| 159 | self.bn3 = norm_layer(channels=planes * self.expansion) |
| 160 | self.act = get_act_layer(name=act) |
| 161 | self.downsample = downsample |
| 162 | self.stride = stride |
| 163 | |
| 164 | def forward(self, x: torch.Tensor) -> torch.Tensor: |
| 165 | residual = x |
nothing calls this directly
no test coverage detected