Delete references between variable and .backward

Hi,

I’m trying to reproduce a code from chainer to PyTorch. I would like to know if there is a way to perform the chainer method unchain_backward() in PyTorch. This method deletes references between variable nodes and functions backward.

Thanks,

Medhy

I’m not completely sure, but I think .detach() should be the equivalent method.

1 Like

I was thinking to use .detach too, but not sure. I’ll try. Thank you for your reply @ptrblck.

I’m not sure which references you want deleted, but if you want to make sure you’re not keeping from deallocation anything but the result you’re returning, input.detach() is right.

1 Like

Yes it is the idea. Thanks