MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / VGGLoss

Class VGGLoss

SRGAN/loss.py:15–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13# phi_5,4 5th conv layer before maxpooling but after activation
14
15class VGGLoss(nn.Module):
16 def __init__(self):
17 super().__init__()
18 #features map = [1, 512, 14, 14]
19 self.vgg = vgg19(pretrained=True).features[:36].eval().to(config.DEVICE)
20 print(self.vgg)
21 self.loss = nn.MSELoss()
22
23 for param in self.vgg.parameters():
24 param.requires_grad = False
25
26 def forward(self, input, target):
27 vgg_input_features = self.vgg(input)
28 vgg_target_features = self.vgg(target)
29 return self.loss(vgg_input_features, vgg_target_features)
30
31if __name__ == '__main__':
32 # vgg = vgg19(pretrained = True)

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected