exact_hessian
- hybrid_learning.concepts.train_eval.hessian.exact_hessian(fn, params, device=None)[source]
Compute all second derivatives of a scalar w.r.t. parameters.
The order of parameters corresponds to a one-dimensional vectorization followed by a concatenation of all tensors in parameters.
- Parameters
- Returns
Hessian of
f
with respect to the concatenated version of all flattened quantities inparameters
- Return type
Note
The parameters in the list are all flattened and concatenated into one large vector
theta
. Return the matrix \(d^2 E / d \theta^2\) withRelated work:: The code is a modified version of https://discuss.pytorch.org/t/compute-the-hessian-matrix-of-a-network/15270/3