(self, x)
| 166 | |
| 167 | |
| 168 | def forward(self, x): |
| 169 | |
| 170 | # if input is list, combine batch dimension |
| 171 | is_list = isinstance(x, tuple) or isinstance(x, list) |
| 172 | if is_list: |
| 173 | batch_dim = x[0].shape[0] |
| 174 | x = torch.cat(x, dim=0) |
| 175 | |
| 176 | x = self.conv1(x) |
| 177 | x = self.norm1(x) |
| 178 | x = self.relu1(x) |
| 179 | |
| 180 | x = self.layer1(x) |
| 181 | x = self.layer2(x) |
| 182 | x = self.layer3(x) |
| 183 | |
| 184 | x = self.conv2(x) |
| 185 | |
| 186 | if self.training and self.dropout is not None: |
| 187 | x = self.dropout(x) |
| 188 | |
| 189 | if is_list: |
| 190 | x = torch.split(x, [batch_dim, batch_dim], dim=0) |
| 191 | |
| 192 | return x |
| 193 | |
| 194 | |
| 195 | class SmallEncoder(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected