Hi all,
I’d like to do something conceptually simple but not sure how to implement it in practice:
f(x).backward()
grad_x = x.grad
#stuff
f(y) = f(x + u(g)).backward()
grad_g = g.grad
#stuff
I’d like to be able to do this in an on-the-fly manner i.e, without maintaining two separate graphs for f(x) and f(y), as these will be user-specific. Ideally I’d like to be able to do an in-place operation on x: y = x+ u(g) and then re-pass this to f(y). Is this possible in PyTorch?