Created
April 19, 2018 01:42
-
-
Save KeremTurgutlu/42af763d5f30b7718dbf9cf45986fdda to your computer and use it in GitHub Desktop.
unet down block in pytorch
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
# a sample down block | |
def make_conv_bn_relu(in_channels, out_channels, kernel_size=3, stride=1, padding=1): | |
return [ | |
nn.Conv2d(in_channels, out_channels, kernel_size=kernel_size, stride=stride, padding=padding, bias=False), | |
nn.BatchNorm2d(out_channels), | |
nn.ReLU(inplace=True) | |
] | |
self.down1 = nn.Sequential( | |
*make_conv_bn_relu(in_channels, 64, kernel_size=3, stride=1, padding=1 ), | |
*make_conv_bn_relu(64, 64, kernel_size=3, stride=1, padding=1 ), | |
) | |
# convolutions followed by a maxpool | |
down1 = self.down1(x) | |
out1 = F.max_pool2d(down1, kernel_size=2, stride=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment