| 157 | class autoencoder_vgg4(nn.Module): # 35.54 PSNR 36.05 BCELoss (120x120) |
| 158 | ''' vgg encoder with bilinear upsampling''' |
| 159 | def __init__(self): |
| 160 | super(autoencoder_vgg4, self).__init__() |
| 161 | self.encoder = models.vgg19(pretrained=True).features |
| 162 | # receptive field not equal? so maybe it does not work very well |
| 163 | self.decoder = nn.Sequential( |
| 164 | # (b, 512, 14, 14) |
| 165 | # nn.UpsamplingBilinear2d(scale_factor=2), # upsample to feature map's size |
| 166 | nn.Conv2d(512, 512, 3, stride=1, padding=1), |
| 167 | nn.ReLU(True), |
| 168 | # (b, 256, 56, 56) |
| 169 | # nn.UpsamplingBilinear2d(scale_factor=4), |
| 170 | nn.Conv2d(512, 256, 3, stride=1, padding=1), |
| 171 | nn.ReLU(True), |
| 172 | # (b, 64, 224, 224) |
| 173 | # nn.UpsamplingBilinear2d(scale_factor=4), |
| 174 | nn.Conv2d(256, 64, 3, stride=1, padding=1), |
| 175 | nn.ReLU(True), |
| 176 | nn.Conv2d(64, 3, 3, stride=1, padding=1), |
| 177 | # nn.Tanh() # MSELoss |
| 178 | nn.Sigmoid() # BCELoss |
| 179 | ) |
| 180 | def forward(self, x): |
| 181 | # pdb.set_trace() |
| 182 | feat = [] |