mygrad.Tensor.clear_graph#

Tensor.clear_graph()[source]#

Removes the current tensor – and tensors above it – from their shared computational graph.

This de-references all operations involved in the graph and the intermediate tensors that were created by it. Arrays whose memory were locked by the computational graph will have their writeability restored.

Examples

>>> import mygrad as mg
>>> import numpy as np
>>> x = np.array([1., 2.])
>>> y = mg.multiply(2., x)
>>> x.flags.writeable, y.creator
(False, <mygrad.math.arithmetic.ops.Multiply at 0x224f89cac48>)
>>> y.clear_graph()
>>> x.flags.writeable, y.creator
(True, None)