Hi,
I already tried and also looked for other posts on the forum but I don’t get it.
I have two models and I want to combine them.
can anyone give a quick example?
class ResNet18Server(nn.Module):
def __init__(self, config):
super(ResNet18Server, self).__init__()
self.logits = config["logits"]
self.cut_layer = config["cut_layer"]
self.model = models.resnet18(pretrained=False)
num_ftrs = self.model.fc.in_features
self.model.fc = nn.Sequential(nn.Flatten(),
nn.Linear(num_ftrs, self.logits))
self.model = nn.ModuleList(self.model.children())
self.model = nn.Sequential(*self.model)
def forward(self, x):
for i, l in enumerate(self.model):
if i <=self.cut_layer:
continue
x = l(x)
return x