Hi, did you solve this problem? I’m also trying to manipulate the weights in the second model with the outputs of the first model. The following is the foward function in second model:
def forward(self, x, kernel, bias):
self.conv[0].weight.data = self.conv[0].weight.data*kernel
self.conv[0].bias.data = self.conv[0].bias.data +torch.squeeze(bias)
out = self.conv(x)
return out
where kernel and bias are the output of the first model. But I got the error message
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
Do you have any idea to solve this problem?