I want to copy a pre-defined
nn.Sequential() like the
layer1 and make a new module that is trainable, without going through the pain of using
_make_layer function. Is there an easy and safe way to do this?
Something like this:
class MyModel(): def __init__(self): model = torchvision.models.resnet18(pretrained=True) self.layer1 = model.layer1 self.layer11 = safe_copy_way(self.layer1) def forward(self, x): x = self.layer1(x) x = self.layer11(x) return x