Suppose my loss is computed with a variable which was the output of my model, i.e.
loss = A (will constantly change in the subsequent iterations depending on the gradient) + B (was an output of the model, but is fixed after that)
How do i call loss.backward()?
I keep getting
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
The problem seems to be that I can’t let B be fixed, since it was the output of the model and it somehow thought it needs some buffers of B.
I do not want to retain any buffer (there shouldn’t be any reason I need to, should there? B is supposed to be fixed throughout, just passing through the model once), I just want a fresh iteration of backpropagation with A being updated based on the gradient and B fixed.