Kaneda
(Kaneda)
October 20, 2020, 8:11pm
1
I got a quick question about ResNet, i don’t really get the idea behind how to define that we want 20 stacked, or 32 stacked layers for example
def resnet20():
return ResNet(BasicBlock, [3, 3, 3])
def resnet32():
return ResNet(BasicBlock, [5, 5, 5])
why [3,3,3] for resnet20 and [5,5,5] for resnet32, exactly what those numbers do?
code https://github.com/akamaster/pytorch_resnet_cifar10/blob/master/resnet.py
YASJAY
(Srinath)
October 20, 2020, 9:29pm
2
Hi @Kaneda , from the code it looks like the [3,3,3] or the [5,5,5] is an argument “num_blocks” to the function _make_layer which is being used to decide strides for different layers.
def _make_layer(self, block, planes, num_blocks, stride):
strides = [stride] + [1]*(num_blocks-1)
layers =
for stride in strides:
layers.append(block(self.in_planes, planes, stride))
self.in_planes = planes * block.expansion
return nn.Sequential(*layers)