Last active
September 23, 2018 13:06
-
-
Save jalola/43951c0f9c088435d112f3cf86f46088 to your computer and use it in GitHub Desktop.
Revisions
-
jalola revised this gist
Sep 23, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ class ImageScale(nn.Module): def __init__(self): super().__init__() self.denorminator = torch.full((3, sz, sz), 255.0, device=torch.device("cuda")) def forward(self, x): return torch.div(x, self.denorminator).unsqueeze(0) # We need to: -
jalola created this gist
Sep 23, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ class ImageScale(nn.Module): def __init__(self): super().__init__() self.denorminator = torch.full((3, sz, sz), 255.0, device=torch.device("cuda")) def forward(self, x): return torch.div(x, self.denorminator).unsqueeze(0) # We need to: # - Add ImageScale by 255.0 at the front # - Replace LogSoftmax layer with Softmax at the end to get probability instead of loss/cost final_model = [ImageScale()] + (list(learn.model.children())[:-1] + [nn.Softmax()]) final_model = nn.Sequential(*final_model)