giagrad.Tensor.backward#

Tensor.backward(retain_graph=False)[source]#

Computes the gradient of all preceeding tensors.

The graph is differentiated using the chain rule. Whether it is scalar or non-scalar (i.e. its data has more than one element), gradient is set to ones and backpropagated.

This function accumulates gradients in every preceeding tensor, you might need to zero .grad attributes or set them to None before calling it.

Parameters:

retain_graph (bool, default: False) – If False the graph used to compute the grads will be freed.