(self, x)
| 237 | nn.Sigmoid() # BCELoss |
| 238 | ) |
| 239 | def forward(self, x): |
| 240 | # pdb.set_trace() |
| 241 | feat = [] |
| 242 | feat_out = [] # we only use high level features |
| 243 | for i in range(len(self.encoder)): |
| 244 | # print("layer {} encoder layer: {}".format(i, self.encoder[i])) |
| 245 | x = self.encoder[i](x) |
| 246 | if i == 3: # ReLU-4 |
| 247 | # pdb.set_trace() |
| 248 | feat.append(x) |
| 249 | elif i == 8: # ReLU-9 |
| 250 | # pdb.set_trace() |
| 251 | feat.append(x) |
| 252 | elif i == 17: # ReLU-18 |
| 253 | # pdb.set_trace() |
| 254 | feat.append(x) |
| 255 | elif i == 26: # ReLU-27 |
| 256 | # pdb.set_trace() |
| 257 | feat.append(x) |
| 258 | elif i == 35: # ReLU-36 |
| 259 | # pdb.set_trace() |
| 260 | feat.append(x) |
| 261 | # pdb.set_trace() |
| 262 | for i in range(len(self.decoder)): |
| 263 | # print("layer {} decoder layer: {}".format(i, self.decoder[i])) |
| 264 | x = self.decoder[i](x) |
| 265 | if i == 1: |
| 266 | # pdb.set_trace() |
| 267 | _, _, h, w = feat[4].shape |
| 268 | x = nn.UpsamplingBilinear2d(size=(h,w))(x) |
| 269 | x = x + feat[4] |
| 270 | elif i == 3: |
| 271 | # pdb.set_trace() |
| 272 | _, _, h, w = feat[3].shape |
| 273 | x = nn.UpsamplingBilinear2d(size=(h,w))(x) |
| 274 | x = x + feat[3] |
| 275 | elif i == 5: |
| 276 | # pdb.set_trace() |
| 277 | _, _, h, w = feat[2].shape |
| 278 | x = nn.UpsamplingBilinear2d(size=(h,w))(x) |
| 279 | x = x + feat[2] |
| 280 | feat_out.append(x) |
| 281 | elif i == 7: |
| 282 | # pdb.set_trace() |
| 283 | _, _, h, w = feat[1].shape |
| 284 | x = nn.UpsamplingBilinear2d(size=(h,w))(x) |
| 285 | x = x + feat[1] |
| 286 | feat_out.append(x) |
| 287 | elif i == 9: |
| 288 | # pdb.set_trace() |
| 289 | _, _, h, w = feat[0].shape |
| 290 | x = nn.UpsamplingBilinear2d(size=(h,w))(x) |
| 291 | x = x + feat[0] |
| 292 | feat_out.append(x) |
| 293 | return feat_out, x |
| 294 | |
| 295 | class autoencoder_vgg6(nn.Module): # robust feature extractors |
| 296 | ''' vgg encoder with bilinear upsampling''' |
nothing calls this directly
no outgoing calls
no test coverage detected