forked from mrq/DL-Art-School
Half channel sizes in cifar_resnet
This commit is contained in:
parent
aea12e1b9c
commit
220f11a5e4
|
@ -85,20 +85,20 @@ class ResNet(nn.Module):
|
|||
def __init__(self, block, num_block, num_classes=100):
|
||||
super().__init__()
|
||||
|
||||
self.in_channels = 64
|
||||
self.in_channels = 32
|
||||
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.Conv2d(3, 64, kernel_size=3, padding=1, bias=False),
|
||||
nn.BatchNorm2d(64),
|
||||
nn.Conv2d(3, 32, kernel_size=3, padding=1, bias=False),
|
||||
nn.BatchNorm2d(32),
|
||||
nn.ReLU(inplace=True))
|
||||
#we use a different inputsize than the original paper
|
||||
#so conv2_x's stride is 1
|
||||
self.conv2_x = self._make_layer(block, 64, num_block[0], 1)
|
||||
self.conv3_x = self._make_layer(block, 128, num_block[1], 2)
|
||||
self.conv4_x = self._make_layer(block, 256, num_block[2], 2)
|
||||
self.conv5_x = self._make_layer(block, 512, num_block[3], 2)
|
||||
self.avg_pool = nn.AdaptiveAvgPool2d((1, 1))
|
||||
self.fc = nn.Linear(512 * block.expansion, num_classes)
|
||||
self.conv2_x = self._make_layer(block, 32, num_block[0], 1)
|
||||
self.conv3_x = self._make_layer(block, 64, num_block[1], 2)
|
||||
self.conv4_x = self._make_layer(block, 128, num_block[2], 2)
|
||||
self.conv5_x = self._make_layer(block, 256, num_block[3], 2)
|
||||
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
|
||||
self.fc = nn.Linear(256 * block.expansion, num_classes)
|
||||
|
||||
def _make_layer(self, block, out_channels, num_blocks, stride):
|
||||
"""make resnet layers(by layer i didnt mean this 'layer' was the
|
||||
|
@ -131,7 +131,7 @@ class ResNet(nn.Module):
|
|||
output = self.conv3_x(output)
|
||||
output = self.conv4_x(output)
|
||||
output = self.conv5_x(output)
|
||||
output = self.avg_pool(output)
|
||||
output = self.avgpool(output)
|
||||
output = output.view(output.size(0), -1)
|
||||
output = self.fc(output)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user