I have trained an autoencoder and saved this trained mode. In another notebook I have uploaded this network:

def load_checkpoint(filepath, model):
checkpoint = torch.load(filepath)
model.load_state_dict(checkpoint[‘state_dict’])
for parameter in model.parameters():
parameter.requires_grad = True
model.train()
return model

Here I set

parameter.requires_grad=True and also model.train()

Then I define a new network called logits_net and this network is trained with the output images of the pre-trained encoder which has been loaded. Loss is calculated by policy gradient method and then I propagate this loss in both networks. this way:

params = list(logits_net.parameters()) + list(model.parameters())
opt = Adam(params, lr=lr)

then

opt.zero_grad()
batch_loss = compute_loss(logp = torch.as_tensor(batch_logp, dtype=torch.float32),  weights = torch.as_tensor(batch_weights, dtype=torch.float32))
batch_loss.backward()
opt.step()

After this I check the gradient of autoencoder parameters and they are all none. The other network’s parameters have gradients.
I am wondering why they do not get trained despite the fact that I have set

parameter.requires_grad=True and also model.train()
and also included the parameters into  the optimizer function.