(dim: int, batch_norm: bool)
| 188 | """Create a residual block.""" |
| 189 | |
| 190 | def _create_block(dim: int, batch_norm: bool) -> list[nn.Module]: |
| 191 | layers = [ |
| 192 | nn.ReLU(False), |
| 193 | nn.Conv2d( |
| 194 | num_features, |
| 195 | num_features, |
| 196 | kernel_size=3, |
| 197 | stride=1, |
| 198 | padding=1, |
| 199 | bias=not batch_norm, |
| 200 | ), |
| 201 | ] |
| 202 | if batch_norm: |
| 203 | layers.append(nn.BatchNorm2d(dim)) |
| 204 | return layers |
| 205 | |
| 206 | residual = nn.Sequential( |
| 207 | *_create_block(dim=num_features, batch_norm=batch_norm), |
nothing calls this directly
no outgoing calls
no test coverage detected