Skip to main content

DenseGGN

DenseGGN(fisher='exact', mc_samples=None, observed=False, joint=False)

Dense GGN, \(C_n = J_n^\top H_n J_n\), with \(J_n\) from jacrev.

So \(\bar{C} = \frac{1}{W} \sum_n w_n J_n^\top H_n J_n\). Per block by default: cross-block entries are not stored. fisher picks \(H_n\) (see Fisher); with "empirical" it is the dense empirical Fisher of the per-example gradients. observed=True takes the Hessian of \(-\log p(y \mid f)\) at the batch’s targets.

Parameters

Name Type Description Default
fisher Fisher Which Fisher, "exact", "mc" or "empirical". 'exact'
mc_samples int | None Draws for fisher="mc", at least 1 (1 when None). Refused with another fisher. None
observed bool Use the observed output Hessian at the targets. Needs fisher="exact". False
joint bool Keep one matrix over all blocks, in layout order, as a Joint (laplace-torch’s hessian_structure="full" over several layers). False

Raises

Name Type Description
ValueError fisher is unknown, mc_samples comes without fisher="mc" or is below 1, or observed comes without fisher="exact".