albanD:

if you plan on modifying it inplace, you want to do .clone().detach() .


I plan to create a completely separate computation graph (and don’t want the call of backwards to interfere with each other). For that I am running requires_flag=True immediately after .detach(). Is that the right thing to do?
e.g.
        ##
        wt_new = wt.clone().detach()
        wt_new.requires_grad = True
        l = (wt_new*x - y)**2
        print(f'l = {l}')
        l.backward()