I have the same issue. Is there a way to keep the names of the layers? I am removing the first layer of ResNet and substituting it with another one, but then all the other layer’s names are numbered.
self.backbone = models.resnet50(pretrained=False)
first_layer = torch.nn.Conv2d(12, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
self.backbone = torch.nn.Sequential(first_layer, *list(self.backbone.named_children())[1:])