Thanks for reply. Yes, it is exactly as you said. This is a piece of code, which may help to locate the problem.
(BTW, pytorch version is 1.4.0)
create graph and load weigths for modelA
checkpoint = torch.load(model_path, map_location=device)
modelA = BackboneNet().to(device)
modelA.load_state_dict(checkpoint[‘backbone’])
modelB = AuxNet().to(device)
freeze modelA
for param in modelA.parameters():
param.requires_grad = False
asign modelB to train
optimizer = torch.optim.Adam(
[{
‘params’: modelB.parameters()
}],
lr=base_lr,
weight_decay=weight_decay)