I have a trained model with some parameters.
What I would like to do is to assign to some of those parameters variables that I create, so that I can backpropagate through the variables.
Up until now I have done something like
for p in model.parameters(): p.data = #whatever
But now this won’t work because the backpropagation will not function this way. I need to do something like
myParameter = functionToBackward(parameterToSubstitute) module.parameterToSubstitute = myParameter l = loss(module.forward(input)) l.backward() #use gradient on myParameter
How can I achieve this? Also note that I want to substitute every parameter in the model, so I would like something that works with a for loop or something