I am trying to pretrain a neural network on say cifar before using this trained backbone on another task.
This is trivial if I just need to chop off the last layer and add new layers but how can I approach this to add in skip connections to new layers?
import torch.nn as nn
import torch.nn.functional as F

class ExampleBackbone(nn.Module):
    def __init__(self, num_classes=100):
          super().__init__()
          self.conv1 = nn.Conv2d(3, 16, kernel_size=3,stride=1,padding=1)
          self.bn1 = nn.BatchNorm2d(ch_out, momentum=0.01)
          self.maxpool = nn.MaxPool2d(2,2)
          self.linear = nn.Linear(16, 100)

    def forward(self, x):
          out = self.conv1(x)
          out = self.bn1(out)
          out = self.maxpool(out)
          return F.log_softmax(self.linear(out))


So for my final result I might want to take the output from self.bn1 and plug to a new layer that I have added for my specific task. Is that the best way to structure the backbone?
Thanks