Last active
May 3, 2020 18:55
-
-
Save Blaizzy/bbdc7da99c94e51e7cf5650e7fbf2459 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 conv(ni, nf, kernel_size = 3, actn=True): | |
| layers = [nn.Conv2d(ni, nf, kernel_size, padding=kernel_size//2)] | |
| if actn: layers.append(nn.ReLU(True)) | |
| return nn.Sequential(*layers) | |
| #---------------------- | |
| class ResSequential(nn.Module): | |
| def __init__(self, layers, res_scale=1.0): | |
| super().__init__() | |
| self.res_scale = res_scale # A factor less than 1.0 will help stabelize training | |
| self.layers = nn.Sequential(*layers) | |
| def forward(self, x): return x + self.layers(x) * self.res_scale |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment