-
-
Save Sivaram46/3498ecd8429c9ee6c11afdddfa82a43a 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
# downsample using 1 * 1 convolution | |
downsample = nn.Sequential( | |
nn.Conv2d(64, 128, kernel_size=1, stride=2, bias=False), | |
nn.BatchNorm2d(128) | |
) | |
# First five layers of ResNet34 | |
resnet_blocks = nn.Sequential( | |
nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False), | |
nn.MaxPool2d(kernel_size=2, stride=2), | |
ResidualBlock(64, 64), | |
ResidualBlock(64, 64), | |
ResidualBlock(64, 128, stride=[2, 1], downsample=downsample) | |
) | |
# checking the shape | |
inputs = torch.rand(1, 3, 100, 100) # single 100 * 100 color image | |
outputs = resnet_blocks(inputs) | |
print(outputs.shape) # shape would be (1, 128, 13, 13) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment