Created
November 9, 2020 12:19
-
-
Save seanbenhur/0cb981a9b991b9d65e1ea196855e8ba0 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 _make_layer(self,block,num_res_blocks,int_channels,stride): | |
identity_downsample = None | |
layers = [] | |
if stride!=1 or self.in_channels != int_channels*4: | |
identity_downsample = nn.Sequential(nn.Conv2d(self.in_channels,int_channels*4, | |
kernel_size=1,stride=stride), | |
nn.BatchNorm2d(int_channels*4)) | |
layers.append(ResBlock(self.in_channels,int_channels,identity_downsample,stride)) | |
#this expansion size will always be 4 for all the types of ResNets | |
self.in_channels = int_channels*4 | |
for i in range(num_res_blocks-1): | |
layers.append(ResBlock(self.in_channels,int_channels)) | |
return nn.Sequential(*layers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment