Last active
May 5, 2020 17:23
-
-
Save Blaizzy/862aabff5083ce6b2e8e40198f6efd37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def forward(self, input, target): | |
| res = [F.l1_loss(input, target) / 100] # pixel loss | |
| in_fts = self.make_fts(input, True) # extracting activations for predicted image | |
| out_fts = self.make_fts(target) # extracting activations for ground-truth image | |
| res+= [F.l1_loss(inp, targ.features) * w | |
| for inp, targ, w in zip(in_fts, out_fts, self.wgts)] # Perceptual loss | |
| return sum(res) | |
| def close(self): | |
| for o in self.sfs: o.remove() # This removes the activations from your memory. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment