Last active
September 23, 2018 13:06
-
-
Save jalola/43951c0f9c088435d112f3cf86f46088 to your computer and use it in GitHub Desktop.
This file contains 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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment