(self, channels, use_conv, dims=2, out_channels=None, padding=1, third_down=False)
| 175 | """ |
| 176 | |
| 177 | def __init__(self, channels, use_conv, dims=2, out_channels=None, padding=1, third_down=False): |
| 178 | super().__init__() |
| 179 | self.channels = channels |
| 180 | self.out_channels = out_channels or channels |
| 181 | self.use_conv = use_conv |
| 182 | self.dims = dims |
| 183 | stride = 2 if dims != 3 else ((1, 2, 2) if not third_down else (2, 2, 2)) |
| 184 | if use_conv: |
| 185 | print(f"Building a Downsample layer with {dims} dims.") |
| 186 | print( |
| 187 | f" --> settings are: \n in-chn: {self.channels}, out-chn: {self.out_channels}, " |
| 188 | f"kernel-size: 3, stride: {stride}, padding: {padding}" |
| 189 | ) |
| 190 | if dims == 3: |
| 191 | print(f" --> Downsampling third axis (time): {third_down}") |
| 192 | self.op = conv_nd( |
| 193 | dims, |
| 194 | self.channels, |
| 195 | self.out_channels, |
| 196 | 3, |
| 197 | stride=stride, |
| 198 | padding=padding, |
| 199 | ) |
| 200 | else: |
| 201 | assert self.channels == self.out_channels |
| 202 | self.op = avg_pool_nd(dims, kernel_size=stride, stride=stride) |
| 203 | |
| 204 | def forward(self, x): |
| 205 | assert x.shape[1] == self.channels |
nothing calls this directly
no test coverage detected