How to have Residual Network using only Sequential Blocks?

I want to implement a ResNet network but I really want it to be in the sequential network form.

What I mean by sequential network form is the following:

    ## mdl5, from cifar10 tutorial
    mdl5 = nn.Sequential(OrderedDict([
        ('pool1', nn.MaxPool2d(2, 2)),
        ('relu1', nn.ReLU()),
        ('conv1', nn.Conv2d(3, 6, 5)),
        ('pool1', nn.MaxPool2d(2, 2)),
        ('relu2', nn.ReLU()),
        ('conv2', nn.Conv2d(6, 16, 5)),
        ('relu2', nn.ReLU()),
        ('Flatten', Flatten()),
        ('fc1', nn.Linear(1024, 120)), # figure out equation properly
        ('relu4', nn.ReLU()),
        ('fc2', nn.Linear(120, 84)),
        ('relu5', nn.ReLU()),
        ('fc3', nn.Linear(84, 10))
    ]))

but of course with the NN lego blocks being “ResNet”.

Thanks!

1 Like
1 Like

related: https://www.reddit.com/r/pytorch/comments/uyyr28/how_to_implement_my_own_resnet_with/